libpysal.cg.voronoi_frames

libpysal.cg.voronoi_frames(points, radius=None, clip='extent')[source]

Composite helper to return Voronoi regions and generator points as individual dataframes

Parameters
pointsarray-like

originator points

radiusfloat

distance to “points at infinity” used in building voronoi cells

clipstr, or shapely.geometry.Polygon

an overloaded option about how to clip the voronoi cells. The options are: - ‘none’/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.

  • ‘bbox’/’extent’/’bounding box’: clip the voronoi cells to the

    bounding box of the input points.

  • ‘chull’/’convex hull’: clip the voronoi cells to the convex hull

    of the input points.

  • ‘ashape’/’ahull’: clip the voronoi cells to the tightest hull that

    contains all points (e.g. the smallest alphashape, using libpysal.cg.alpha_shape_auto)

  • Polygon: clip to an arbitrary Polygon

tolerancefloat

percent of map width to use to buffer the extent of the map, if clipping (default: .01, or 1 percent)

Returns
_tuple

(region_df, points_df)

region_dfGeoDataFrame (if geopandas available, otherwise Pandas DataFrame)

Finite Voronoi polygons as geometries

points_dfGeoDataFrame (if geopandas available, otherwise Pandas DataFrame)

Originator points as geometries

Notes

If Geopandas is not available the return types will be Pandas DataFrames each with a geometry column populated with PySAL shapes. If Geopandas is available, return types are GeoDataFrames with a geometry column populated with shapely geometry types.

Examples

>>> points = [(10.2, 5.1), (4.7, 2.2), (5.3, 5.7), (2.7, 5.3)]
>>> regions_df, points_df = voronoi_frames(points)
>>> regions_df.shape
(4, 1)
>>> regions_df.shape == points_df.shape
True