# shapely.voronoi_polygons#

voronoi_polygons(geometry, tolerance=0.0, extend_to=None, only_edges=False, ordered=False, **kwargs)#

Computes a Voronoi diagram from the vertices of an input geometry.

The output is a geometrycollection containing polygons (default) or linestrings (see only_edges). Returns empty if an input geometry contains less than 2 vertices or if the provided extent has zero area.

Parameters:
geometryGeometry or array_like
tolerancefloat or array_like, default 0.0

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

extend_toGeometry or array_like, optional

If provided, the diagram will be extended to cover the envelope of this geometry (unless this envelope is smaller than the input geometry).

only_edgesbool or array_like, default False

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

orderedbool or array_like, default False

If set to True, polygons within the GeometryCollection will be ordered according to the order of the input vertices. Note that this may slow down the computation. Requires GEOS >= 3.12.0

**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

```>>> from shapely import LineString, MultiPoint, Point
>>> points = MultiPoint([(2, 2), (4, 2)])
>>> voronoi_polygons(points).normalize()
<GEOMETRYCOLLECTION (POLYGON ((3 0, 3 4, 6 4, 6 0, 3 0)), POLYGON ((0 0, 0 4...>
>>> voronoi_polygons(points, only_edges=True)
<MULTILINESTRING ((3 4, 3 0))>
>>> voronoi_polygons(MultiPoint([(2, 2), (4, 2), (4.2, 2)]), 0.5, only_edges=True)
<MULTILINESTRING ((3 4.2, 3 -0.2))>
>>> voronoi_polygons(points, extend_to=LineString([(0, 0), (10, 10)]), only_edges=True)
<MULTILINESTRING ((3 10, 3 0))>
>>> voronoi_polygons(LineString([(2, 2), (4, 2)]), only_edges=True)
<MULTILINESTRING ((3 4, 3 0))>
>>> voronoi_polygons(Point(2, 2))
<GEOMETRYCOLLECTION EMPTY>
>>> voronoi_polygons(points, ordered=True)
<GEOMETRYCOLLECTION (POLYGON ((0 0, 0 4, 3 4, 3 0, 0 0)), POLYGON ((6 4, 6 0...>
```