dtoolkit.geoaccessor.geodataframe.voronoi#

dtoolkit.geoaccessor.geodataframe.voronoi(df: gpd.GeoDataFrame, /, boundary: Polygon | MultiPolygon = None, only_edges: bool = False) gpd.GeoSeries[source]#

Computes a Voronoi diagram from Point geometry.

Parameters:
boundaryPolygon or MultiPolygon, optional

The outer boundary of the diagram. If None, use the convex hull of the inputs.

only_edgesbool, default False

If True, only return the edges.

Returns:
GeoSeries
Raises:
TypeError

If the geometry type is not Point.

IndexError

If the length of the GeoSeries is less than 3.

Notes

These Points may construct a polygon.

Examples

>>> import dtoolkit.geoaccessor
>>> import geopandas as gpd
>>> df = gpd.GeoDataFrame(geometry=gpd.points_from_xy([0, 1, 2], [0, 1, 0]))
>>> df
                  geometry
0  POINT (0.00000 0.00000)
1  POINT (1.00000 1.00000)
2  POINT (2.00000 0.00000)
>>> df.voronoi()
0    POLYGON ((1.00000 0.00000, 0.00000 0.00000, 0....
2    POLYGON ((1.50000 0.50000, 2.00000 0.00000, 1....
1    POLYGON ((1.00000 0.00000, 0.50000 0.50000, 1....
dtype: geometry