使用小于3点的em生成
def get_voronoi_polygons(points_dict):
points = np.array(list(points_dict.values()))[:, :2]
# points = [[79.95818 6.865576][79.941176 6.923571]] #gives error
# points = [['79.95818' '6.865576']['79.919' '6.908']['79.885825' '6.860887']] #working fine
print(points)
vor = Voronoi(points)
voronoi_plot_2d(vor)
plt.show()
以下是使用2点时显示的错误
File "/home/hasitha/PycharmProjects/Workflow/polygon/gen_polygon.py", line 119, in get_voronoi_polygons
vor = Voronoi(points)
File "qhull.pyx", line 2518, in scipy.spatial.qhull.Voronoi.__init__
File "qhull.pyx", line 354, in scipy.spatial.qhull._Qhull.__init__
scipy.spatial.qhull.QhullError: QH6214 qhull input error: not enough points(2) to construct initial simplex (need 4)
While executing: | qhull v Qbb Qc Qz
Options selected for Qhull 2015.2.r 2016/01/18:
run-id 1125400088 voronoi Qbbound-last Qcoplanar-keep Qz-infinity-point
_pre-merge _zero-centrum Qinterior-keep
尽管它说需要4分,但3分也可以正常工作。 也许我误解了“点”的定义。这在哪里定义它需要4分。
P.S。我的实际要求是绘制具有给定点的蒂森多边形