VoronoiRegionalizer
srai.regionalizers.VoronoiRegionalizer(
seeds,
max_meters_between_points=10000,
num_of_multiprocessing_workers=-1,
multiprocessing_activation_threshold=None,
)
¶
srai.regionalizers.VoronoiRegionalizer(
seeds,
max_meters_between_points=10000,
num_of_multiprocessing_workers=-1,
multiprocessing_activation_threshold=None,
)
Bases: Regionalizer
VoronoiRegionalizer.
Voronoi [1] regionalizer allows the given geometries to be divided into Thiessen polygons using geometries that are the seeds. To minimize distortions tessellation will be performed on a sphere using SphericalVoronoi [2] function from scipy library.
References
All (multi)polygons from seeds GeoDataFrame will be transformed to their centroids, because scipy function requires only points as an input.
PARAMETER | DESCRIPTION |
---|---|
seeds |
List of points or a GeoDataFrame with seeds for creating a tessellation. Every non-point geometry will be mapped to a centroid. Minimum 4 seeds are required. Seeds cannot lie on a single arc. Empty seeds will be removed.
TYPE:
|
max_meters_between_points |
Maximal distance in meters between two points in a resulting polygon. Higher number results lower resolution of a polygon.
TYPE:
|
num_of_multiprocessing_workers |
Number of workers used for
multiprocessing. Defaults to
TYPE:
|
multiprocessing_activation_threshold |
Number of seeds required to start processing on multiple processes. Activating multiprocessing for a small amount of points might not be feasible. Defaults to 100.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If any seed is duplicated. |
ValueError
|
If less than 4 seeds are provided. |
ValueError
|
If provided seeds geodataframe has no crs defined. |
ValueError
|
If any seed is outside WGS84 coordinates domain. |
Source code in srai/regionalizers/voronoi_regionalizer.py
¶
Regionalize a given GeoDataFrame.
Returns a list of disjointed regions consisting of Thiessen cells generated using a Voronoi diagram on the sphere.
PARAMETER | DESCRIPTION |
---|---|
gdf |
GeoDataFrame to be regionalized. Will use this list of geometries to crop resulting regions. If None, a boundary box with bounds (-180, -90, 180, 90) is used to return regions covering whole Earth. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
gpd.GeoDataFrame
|
gpd.GeoDataFrame: GeoDataFrame with the regionalized data cropped using input GeoDataFrame. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If provided geodataframe has no crs defined. |
ValueError
|
If seeds are laying on a single arc. |