geopandas.GeoSeries.delaunay_triangles#

GeoSeries.delaunay_triangles(tolerance=0.0, only_edges=False)[source]#

Returns a GeoSeries consisting of objects representing the computed Delaunay triangulation around the vertices of an input geometry.

The output is a GeometryCollection containing polygons (default) or linestrings (see only_edges).

Returns an empty GeometryCollection if an input geometry contains less than 3 vertices.

Parameters:
tolerancefloat | array-like, default 0.0

Snap input vertices together if their distance is less than this value.

only_edgesbool | array_like, (optional, default False)

If set to True, the triangulation will return a collection of linestrings instead of polygons.

Examples

>>> from shapely import LineString, MultiPoint, Polygon
>>> s = geopandas.GeoSeries(
...     [
...         MultiPoint([(5, 3), (6, 3), (10, 10)]),
...         Polygon([(5, 3), (6, 3), (10, 10), (5, 3)]),
...         LineString([(5, 3), (6, 3), (10, 10)]),
...     ]
... )
>>> s
0    MULTIPOINT ((5 3), (6 3), (10 10))
1      POLYGON ((5 3, 6 3, 10 10, 5 3))
2          LINESTRING (5 3, 6 3, 10 10)
dtype: geometry
>>> s.delaunay_triangles()
0    GEOMETRYCOLLECTION (POLYGON ((10 10, 5 3, 6 3,...
1    GEOMETRYCOLLECTION (POLYGON ((10 10, 5 3, 6 3,...
2    GEOMETRYCOLLECTION (POLYGON ((10 10, 5 3, 6 3,...
dtype: geometry
>>> s.delaunay_triangles(only_edges=True)
0    MULTILINESTRING ((5 3, 10 10), (5 3, 6 3), (6 ...
1    MULTILINESTRING ((5 3, 10 10), (5 3, 6 3), (6 ...
2    MULTILINESTRING ((5 3, 10 10), (5 3, 6 3), (6 ...
dtype: geometry