All Projects → WZBSocialScienceCenter → geovoronoi

WZBSocialScienceCenter / geovoronoi

Licence: Apache-2.0 license
a package to create and plot Voronoi regions within geographic boundaries

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to geovoronoi

xyz-spaces-python
Manage your XYZ Hub or HERE Data Hub spaces from Python.
Stars: ✭ 29 (-72.64%)
Mutual labels:  geospatial, geospatial-analysis
glaes
Geospatial Land Availability for Energy Systems
Stars: ✭ 27 (-74.53%)
Mutual labels:  geospatial, geospatial-analysis
leafmap
A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
Stars: ✭ 1,299 (+1125.47%)
Mutual labels:  geospatial, geospatial-analysis
actinia core
Actinia Core is an open source REST API for scalable, distributed, high performance processing of geographical data that uses mainly GRASS GIS for computational tasks (DOI: https://doi.org/10.5281/zenodo.5879231)
Stars: ✭ 41 (-61.32%)
Mutual labels:  geospatial, geospatial-analysis
topo
A Geometry library for Elixir that calculates spatial relationships between two geometries
Stars: ✭ 125 (+17.92%)
Mutual labels:  geospatial
NetCDF.jl
NetCDF support for the julia programming language
Stars: ✭ 102 (-3.77%)
Mutual labels:  geospatial
awesome-geospatial-list
A curated list of geospatial tools, data, tutorials, information, and more
Stars: ✭ 32 (-69.81%)
Mutual labels:  geospatial
python-resources-for-earth-sciences
A Curated List of Python Resources for Earth Sciences
Stars: ✭ 159 (+50%)
Mutual labels:  geospatial
python-geospatial-analysis-cookbook
Over 60 recipes to work with topology, overlays and indoor routing
Stars: ✭ 105 (-0.94%)
Mutual labels:  geospatial-analysis
awesome-geospatial-data-download-sites
This is the repo for open source geospatial data download sites.
Stars: ✭ 19 (-82.08%)
Mutual labels:  geospatial
localtileserver
🌐 dynamic tile server for visualizing rasters in Jupyter with ipyleaflet or folium
Stars: ✭ 190 (+79.25%)
Mutual labels:  geospatial
deegree3
Official deegree repository providing geospatial core libraries, data access and advanced OGC web service implementations
Stars: ✭ 118 (+11.32%)
Mutual labels:  geospatial
rdp
A library providing FFI access to fast Ramer–Douglas–Peucker and Visvalingam-Whyatt line simplification algorithms
Stars: ✭ 20 (-81.13%)
Mutual labels:  geospatial
skeyenet
Road and Building Segmentation in Satellite Imagery
Stars: ✭ 106 (+0%)
Mutual labels:  geospatial
LightOSM.jl
A Julia package for downloading and analysing geospatial data from OpenStreetMap APIs.
Stars: ✭ 32 (-69.81%)
Mutual labels:  geospatial
spatial efd
A spatial aware implementation of elliptical Fourier analysis
Stars: ✭ 19 (-82.08%)
Mutual labels:  geospatial
geos-cli
A native geometry command line library using libgeos.
Stars: ✭ 20 (-81.13%)
Mutual labels:  geospatial
geospatial-learn
A python library for geo-spatial processing and machine learning
Stars: ✭ 20 (-81.13%)
Mutual labels:  geospatial-analysis
2019 egu workshop jupyter notebooks
Short course on interactive analysis of Big Earth Data with Jupyter Notebooks
Stars: ✭ 29 (-72.64%)
Mutual labels:  geospatial-analysis
python-censusbatchgeocoder
A simple Python wrapper for U.S. Census Geocoding Services API batch service
Stars: ✭ 40 (-62.26%)
Mutual labels:  geospatial

geovoronoi – a package to create and plot Voronoi regions inside geographic areas

PyPI version DOI

Markus Konrad [email protected] / [email protected], March 2022

Overview

Voronoi regions of random points across Spain and their respective area

geovoronoi helps generating Voronoi regions for geographic data, for example coordinates of public universities in a certain country. This in turn may be used to estimate some kind of "coverage". The usage is not confined to geographic data, though. This package allows you to generate finite Voronoi regions inside any valid surrounding polygonal shape.

The main function of this package, voronoi_regions_from_coords(), takes a list of coordinates and calculates the Voronoi regions from them using SciPy. At the edges, these regions go to infinity. We can then take the shape of the surrounding area (e.g. the shape of a country as polygon) to cut the Voronoi regions so that they fit into the provided shape, making the regions at the edges finite. geovoronoi uses shapely for these operations. The package furthermore implements some functions for easy plotting of the resulting Voronoi regions.

Installation

This package is available on PyPI. You can install the latest version via pip as follows:

# install with "plotting" dependencies (recommended):
pip install -U geovoronoi[plotting]

# or install base version:
pip install -U geovoronoi

Usage

You have a geographic area that contains some points for which you want to generate Voronoi regions. This geographic area is a shapely Polygon/MultiPolygon object (that you, for example, obtained from a GeoJSON file that you loaded with GeoPandas or Fiona). The N points you have are either in the form of a Nx2 NumPy array, or a list of shapely Point objects (they can be converted with the functions coords_to_points and points_to_coords). Both the points and the surrounding geographic area must be in the same CRS (coordinate reference system).

Let's take for example these randomly generated points in Italy (in World Mercator CRS):

import numpy as np

# coords = ... generate some coordinates with np.random.uniform ...
print(coords)
array([[1690891.43454513, 4865911.53550427],
       [1303898.2749075 , 5398659.4816214 ],
       [1379407.32051822, 5701267.51923313],
       [1703402.05850744, 4916559.63783754],
       ...
       ]])

The surrounding shape of Italy was obtained beforehand from GeoPandas:

import geopandas as gpd

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
area = world[world.name == 'Italy']

area = area.to_crs(epsg=3395)    # convert to World Mercator CRS
area_shape = area.iloc[0].geometry   # get the Polygon

Now we can calculate the Voronoi regions, cut them with the geographic area shape and assign the points to them:

from geovoronoi import voronoi_regions_from_coords

region_polys, region_pts = voronoi_regions_from_coords(coords, area_shape)

region_polys is a dict that maps Voronoi region IDs to shapely Polygon objects that represent the shape of the respective Voronoi region. With them, you can do everything that the shapely API provides. You can, for example, get each Voronoi region's area (there's also a helper function calculate_polygon_areas in geovoronoi for that).

region_pts is a dict that maps the same Voronoi region IDs as in region_polys to a list of indices into coords, i.e. these indices represent the points that belong to this Voronoi region. Usually, this is only a single point. However, in case of duplicate points (i.e. two or more points have exactly the same coordinates) all duplicate points are listed for the respective Voronoi region.

You can plot the results with the functions from the plotting sub-module:

import matplotlib.pyplot as plt
from geovoronoi.plotting import subplot_for_map, plot_voronoi_polys_with_points_in_area

fig, ax = subplot_for_map()
plot_voronoi_polys_with_points_in_area(ax, area_shape, region_polys, coords, region_pts)
plt.show()

This would be an example output:

Voronoi regions of random points across Italy

See the full example source code in examples/random_points_across_italy.py. See also the other examples in the examples/ directory that show how to calculate the area of the Voronoi regions, handle duplicate points or interact with the GeoPandas or Fiona packages.

Dependencies

geovoronoi requires Python 3.6 or newer (the package is tested for up to Python 3.10). The following packages need to be installed (if not, they will be automatically installed if you use a Python package manager like pip):

  • NumPy
  • SciPy
  • shapely
  • matplotlib (only necessary for plotting)
  • geopandas (only necessary for plotting)
  • descartes (only necessary for plotting)

License

Licensed under Apache License 2.0. See LICENSE.txt file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].