The triangulate() function in shapely.ops calculates a Delaunay triangulation from a collection of points.
shapely.ops中的triangulate()函数从一个点集中计算得到一个狄洛尼三角剖分结果。
(Source code, png, hires.png, pdf)
- shapely.ops.triangulate(geom, tolerance=0.0, edges=False)
Returns a Delaunay triangulation of the vertices of the input geometry.
返回输入几何对象的狄洛尼三角剖分图。
The source may be any geometry type. All vertices of the geometry will be used as the points of the triangulation.
可以是任何几何对象类型。该几何对象的所有顶点都将被用作三角形的点。
The tolerance keyword argument sets the snapping tolerance used to improve the robustness of the triangulation computation. A tolerance of 0.0 specifies that no snapping will take place.
容差参数的设置用于提高三角计算的稳健性。容差为0.0表示不进行捕获。
If the edges keyword argument is False a list of Polygon triangles will be returned. Otherwise a list of LineString edges is returned.
如果edges参数为False,将返回Polygon三角形的列表。否则将返回一个LineString边界的列表。
New in version 1.4.0
>>> from shapely.ops import triangulate
>>> points = MultiPoint([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
>>> triangles = triangulate(points)
>>> pprint([triangle.wkt for triangle in triangles])
['POLYGON ((0 2, 0 0, 1 1, 0 2))',
'POLYGON ((0 2, 1 1, 2 2, 0 2))',
'POLYGON ((2 2, 1 1, 3 1, 2 2))',
'POLYGON ((3 1, 1 1, 1 0, 3 1))',
'POLYGON ((1 0, 1 1, 0 0, 1 0))']