geopandas.GeoSeries.delaunay_triangles#
- GeoSeries.delaunay_triangles(tolerance=0.0, only_edges=False)[来源]#
返回一个
GeoSeries,该对象表示输入几何图形的顶点之间计算得到的 Delaunay 三角剖分。GeoSeries 中的所有几何图形在单个 Delaunay 三角剖分中被一起考虑。因此,生成的几何图形与输入几何图形并不是 1:1 对应。请注意,几何图形的每个顶点都被视为三角剖分的一个点,因此三角形将在每个几何图形的顶点之间构建。
- Parameters:
- tolerancefloat, default 0.0
如果输入顶点之间的距离小于此值,则将它们合并在一起。
- only_edgesbool (optional, default False)
如果设置为 True,三角剖分将返回线串而不是多边形。
另请参阅
GeoSeries.voronoi_polygons围绕顶点的Voronoi图
笔记
如果您想为每个几何体单独生成德劳内三角形,请使用
shapely.delaunay_triangles()。示例
>>> from shapely import LineString, MultiPoint, Point, Polygon >>> s = geopandas.GeoSeries( ... [ ... Point(1, 1), ... Point(2, 2), ... Point(1, 3), ... Point(0, 2), ... ] ... ) >>> s 0 POINT (1 1) 1 POINT (2 2) 2 POINT (1 3) 3 POINT (0 2) dtype: geometry
>>> s.delaunay_triangles() 0 POLYGON ((0 2, 1 1, 1 3, 0 2)) 1 POLYGON ((1 3, 1 1, 2 2, 1 3)) dtype: geometry
>>> s.delaunay_triangles(only_edges=True) 0 LINESTRING (1 3, 2 2) 1 LINESTRING (0 2, 1 3) 2 LINESTRING (0 2, 1 1) 3 LINESTRING (1 1, 2 2) 4 LINESTRING (1 1, 1 3) dtype: geometry
该方法支持任何几何类型,但请记住,底层算法仅基于输入几何的顶点,不考虑顶点之间的边段。
>>> s2 = geopandas.GeoSeries( ... [ ... Polygon([(0, 0), (1, 1), (0, 1)]), ... LineString([(1, 0), (2, 1), (1, 2)]), ... MultiPoint([(2, 3), (2, 0), (3, 1)]), ... ] ... ) >>> s2 0 POLYGON ((0 0, 1 1, 0 1, 0 0)) 1 LINESTRING (1 0, 2 1, 1 2) 2 MULTIPOINT ((2 3), (2 0), (3 1)) dtype: geometry
>>> s2.delaunay_triangles() 0 POLYGON ((0 1, 0 0, 1 0, 0 1)) 1 POLYGON ((0 1, 1 0, 1 1, 0 1)) 2 POLYGON ((0 1, 1 1, 1 2, 0 1)) 3 POLYGON ((1 2, 1 1, 2 1, 1 2)) 4 POLYGON ((1 2, 2 1, 2 3, 1 2)) 5 POLYGON ((2 3, 2 1, 3 1, 2 3)) 6 POLYGON ((3 1, 2 1, 2 0, 3 1)) 7 POLYGON ((2 0, 2 1, 1 1, 2 0)) 8 POLYGON ((2 0, 1 1, 1 0, 2 0)) dtype: geometry