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:
- pointsnumpy:array_like
The originator points.
- radius
python:float The distance to ‘points at infinity’ used in building voronoi cells. Default is
None.- clip{
python:str,shapely.geometry.Polygon} An overloaded option about how to clip the voronoi cells. Default is
'extent'. Options are as follows.'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, usinglibpysal.cg.alpha_shape_auto).Polygon – Clip to an arbitrary Polygon.
- Returns:
- reg_vtx
python:tuple Two
geopandas.GeoDataFrame(orpandas.DataFrameifgeopandasis unavailable) objects–(region_df, points_df)–of finite Voronoi polygons and the originator points as geometries.
- reg_vtx
Notes
If
geopandasis not available the return types will bepandas.DataFrameobjects, each with a geometry column populated with PySAL shapes. Ifgeopandasis available, return types arepandas.GeoDataFrameobjects 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