shapely.delaunay_triangles#
- delaunay_triangles(geometry, tolerance=0.0, only_edges=False, **kwargs)#
Computes a Delaunay triangulation around the vertices of an input geometry.
The output is a geometrycollection containing polygons (default) or linestrings (see only_edges). Returns an None if an input geometry contains less than 3 vertices.
- Parameters:
- geometryGeometry or array_like
- tolerancefloat or array_like, default 0.0
Snap input vertices together if their distance is less than this value.
- only_edgesbool or array_like, default False
If set to True, the triangulation will return a collection of linestrings instead of polygons.
- **kwargs
For other keyword-only arguments, see the NumPy ufunc docs.
Examples
>>> from shapely import GeometryCollection, LineString, MultiPoint, Polygon >>> points = MultiPoint([(50, 30), (60, 30), (100, 100)]) >>> delaunay_triangles(points) <GEOMETRYCOLLECTION (POLYGON ((50 30, 60 30, 100 100, 50 30)))> >>> delaunay_triangles(points, only_edges=True) <MULTILINESTRING ((50 30, 100 100), (50 30, 60 30), ...> >>> delaunay_triangles(MultiPoint([(50, 30), (51, 30), (60, 30), (100, 100)]), tolerance=2) <GEOMETRYCOLLECTION (POLYGON ((50 30, 60 30, 100 100, 50 30)))> >>> delaunay_triangles(Polygon([(50, 30), (60, 30), (100, 100), (50, 30)])) <GEOMETRYCOLLECTION (POLYGON ((50 30, 60 30, 100 100, 50 30)))> >>> delaunay_triangles(LineString([(50, 30), (60, 30), (100, 100)])) <GEOMETRYCOLLECTION (POLYGON ((50 30, 60 30, 100 100, 50 30)))> >>> delaunay_triangles(GeometryCollection([])) <GEOMETRYCOLLECTION EMPTY>