当前位置: 首页>>代码示例>>Python>>正文


Python Point.idx方法代码示例

本文整理汇总了Python中shapely.geometry.Point.idx方法的典型用法代码示例。如果您正苦于以下问题:Python Point.idx方法的具体用法?Python Point.idx怎么用?Python Point.idx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shapely.geometry.Point的用法示例。


在下文中一共展示了Point.idx方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Point

# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import idx [as 别名]
shapePoints = []

circleRadius = random.randint(500, 1500)
circleX = random.randint(0, gridWidth)
circleY = random.randint(0, gridHeight)

sCircle = Point(circleX, circleY)
sCircle = sCircle.buffer(circleRadius, 16)

pointList = []
for i in range(numberOfPoints):
	x = random.randint(0, gridWidth)
	y = random.randint(0, gridHeight)
	pointList.append((x, y))
	iPoint = Point(x, y)
	iPoint.idx = i # set our custom attribute. (if this doesnt work I have other ways)
	shapePoints.append(iPoint)

matchingPoints = []
searchBench = time.time()
for idx, point in enumerate(shapePoints):
	if sCircle.contains(point):
		matchingPoints.append(idx)

searchBench = time.time() - searchBench

print "There were %d points within the circle [%d, %d] - r[%d]\n" % (len(matchingPoints), circleX, circleY, circleRadius)
print "Calculation Took %s seconds for %s points" % (searchBench, numberOfPoints)
print "Saving Graph to %s" % (filename)

开发者ID:bendemott,项目名称:Python-Shapely-Examples,代码行数:31,代码来源:shapelyAreaSearch.py

示例2: Point

# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import idx [as 别名]
'''
Because shapely api objects are in fact objects we should be able to set
arbitrary properties on the objects. This is useful if you want the shapely
object to relate back to a OBJECT_ID or an arbitrary index that references
the object the geometric point/object corresponds to.
'''

from shapely import *
from shapely.geometry import Point
myPoint = Point(1.2, 3.0)
myPoint.idx = 'custom_idx'
# Performing operations that creates a new object or modifies the object will
# cause your custom attribute to be lost...
circle = myPoint.buffer(3.0, 16)
circle.idx = myPoint.idx
print circle.idx
开发者ID:bendemott,项目名称:Python-Shapely-Examples,代码行数:18,代码来源:shapelyCustomProperty.py


注:本文中的shapely.geometry.Point.idx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。