libpysal.cg.voronoi_frames

libpysal.cg.voronoi_frames(geometry: GeoSeries | GeoDataFrame | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], radius: float | None = None, clip: str | Geometry | None = 'bounding_box', shrink: float = 0, segment: float = 0, grid_size: float = 1e-05, return_input: bool | None = None, as_gdf: bool | None = None) GeoSeries[source]

Create Voronoi polygons from a GeoSeries of points, lines, or polygons.

This is a wrapper around shapely.voronoi_polygons that handles not only points but also lines and polygons through their discretization and dissolution of the resulting polygons.

Parameters:
geometryGeoSeries | GeoDataFrame | array_like

A GeoSeries of points, lines, or polygons or an array of coordinates.

radiusfloat, optional

Deprecated. Has no effect any longer.

clipstr, shapely.geometry.Polygon, optional

Polygon used to clip the Voronoi polygons, by default “bounding_box” The options are:

  • None – No clip is applied. Voronoi cells may be arbitrarily larger that the source map. Note that this may lead to cells that are many orders of magnitude larger in extent than the original map. Not recommended.

  • 'bounding_box' – Clip the voronoi cells to the bounding box of the input points.

  • 'convex_hull' – Clip the voronoi cells to the convex hull of the input points.

  • 'alpha_shape' – Clip the voronoi cells to the tightest hull that contains all points (e.g. the smallest alpha shape, using libpysal.cg.alpha_shape_auto()).

  • shapely.Polygon – Clip to an arbitrary Polygon.

shrinkfloat, optional

Distance for the negative buffer of polygons required when there are polygons sharing portion of their exterior, by default 0

segmentfloat, optional

Distance for the segmentation of lines used to add coordinates to lines or polygons prior Voronoi tessellation, by default 0

grid_sizefloat, optional

Grid size precision under which the voronoi algorithm is generated, by default 1e-5

return_inputbool, optional

Whether to return the input geometry, defaults to True

as_gdfbool, optional

Whether to return the output as a GeoDataFrame (True) or GeoSeries (False), defaults to True

Returns:
GeoSeries | GeoDataFrame | tuple

GeoSeries of Voronoi polygons with index allowing to link back to the input