我想用下面的函數在我的計劃:如何創建點對象列表?
def computeVoronoiDiagram(points):
""" Takes a list of point objects (which must have x and y fields).
Returns a 3-tuple of:
(1) a list of 2-tuples, which are the x,y coordinates of the
Voronoi diagram vertices
(2) a list of 3-tuples (a,b,c) which are the equations of the
lines in the Voronoi diagram: a*x + b*y = c
(3) a list of 3-tuples, (l, v1, v2) representing edges of the
Voronoi diagram. l is the index of the line, v1 and v2 are
the indices of the vetices at the end of the edge. If
v1 or v2 is -1, the line extends to infinity.
"""
siteList = SiteList(points)
context = Context()
voronoi(siteList,context)
return (context.vertices,context.lines,context.edges)
它說拿點對象(其中有X & Y字段)的列表。它與Python列表數據結構不同嗎?我如何創建這樣的對象? 編輯:我應該提到的列表將包含約百萬個隨機點。
訂購點被表示爲元組:'[(1,2),(3,4)]'。 – Blender
@moooeeeep這是圖書館:https://github.com/rougier/gallery/blob/master/voronoi/voronoi/voronoi.py – rishiag
我已經回答了[此其他圖書館]的解決方案(https:// svn .osgeo.org/qgis/branches/Release-1_6_0/python/plugins/fTools/tools/voronoi.py),這似乎是你的問題之一。爲何差異?這個來自github的不包括你發佈的代碼。 –