本文整理汇总了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)
示例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