voronoi-diagram-for-polygons
A tool to create a Voronoi diagram for polygons
https://github.com/longavailable/voronoi-diagram-for-polygons
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.6%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A tool to create a Voronoi diagram for polygons
Basic Info
- Host: GitHub
- Owner: longavailable
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://longlovemyu.com/voronoi-diagram-for-polygons/
- Size: 743 KB
Statistics
- Stars: 61
- Watchers: 2
- Forks: 13
- Open Issues: 0
- Releases: 2
Topics
Metadata Files
README.md
Voronoi diagram for polygons
Voronoi diagram for polygons is a tool to create a Voronoi diagram also known as Thiessen polygons for polygons. It's based on Shapely and GeoPandas. There are lots of tools to create a Voronoi diagram for points, for example Create Thiessen Polygons (Analysis) in ArcGIS Pro or ArcGIS Desktop, Voronoi Polygons in QGIS, or voronoi_diagram in Shapely. All of them are really cool. How about a Voronoi diagram for polygons? That's what this tool does.
Important! You have to install or upgrade to the latest developing version of Shapely before install Voronoi diagram for polygons
Table of contents
Installation, update and uninstallation
Dependencies
Important! It's based on voronoi_diagram from Shapely which is new in version 1.8.dev0. As of today, it is still a developing version. (2020-07-26) You have to install or upgrade to the latest developing version from source firstly:
bash
pip install git+https://github.com/Toblerity/Shapely
bash
pip install --upgrade git+https://github.com/Toblerity/Shapely
To install
Quick installation with pip:
bash
pip install voronoi-diagram-for-polygons
Or from github:
bash
pip install git+https://github.com/longavailable/voronoi-diagram-for-polygons
Also, you can just copy related functions from longsgis/longsgis.py to your work.
To update
bash
pip install --upgrade voronoi-diagram-for-polygons
To uninstall
bash
pip uninstall voronoi-diagram-for-polygons
Usage
See tests/01voronoiDiagram4plg.py. ```python import geopandas as gpd from longsgis import voronoiDiagram4plg
builtup = gpd.readfile('input.geojson'); builtup.crs = 32650 boundary = gpd.readfile('boundary.geojson'); boundary.crs = 32650 vd = voronoiDiagram4plg(builtup, boundary) vd.to_file('output.geojson', driver='GeoJSON') ```
FAQ
I/O support.
It was noticed someone were struggled with the input/output files with a format of
.geojson(https://github.com/longavailable/voronoi-diagram-for-polygons/issues/3, https://github.com/longavailable/voronoi-diagram-for-polygons/issues/5). Actually, that's not a question related to this package. I will explain more here about it. This package is totally based on GeoPandas. In other words, any format that can be converted togeopandas.GeoDataFrameobject is supported. As the official documentation said:geopandas can read almost any vector-based spatial data format including ESRI shapefile, GeoJSON files and more using the command:
geopandas.read_file()That means, you can put your
.shpfiles as inputs and output as well. Any format you'd like. I used a few geojson-s (input.geojson,boundary.geojson, andoutput.geojson) in my example because the geojson format is very open. However, it's NOT necessary.For more, I upload the input.geojson and boundary.geojson files. Hope they helps. For the sake of caution, I declare here that they are only a test file, any actual geographical data, similar or not, I have no guarantee to the accuracy and authenticity for them.
Known shortages
It may produce multipolygons (consisted by some unconnected polygons) around the boundary.

Special input may cause overlap. See the following:
To avoid this, I recommend reasonable preprocessing of the input, but use a buffer operation with high-resolution carefully. A buffer operation with high-resolution will result in circular arcs, which will generate too many vertices in a local area. This may trigger other bugs. In my practices, the following code snippet worked well.
```python
def bufferDissolve(gdf, distance, join_style=3):
'''Create buffer and dissolve thoese intersects.
Parameters:
gdf:
Type: geopandas.GeoDataFrame
distance: radius of the buffer
Type: float
Returns:
gdf_bf: buffered and dissolved GeoDataFrame
Type: geopandas.GeoDataFrame
'''
#create buffer and dissolve by invoking `unary_union`
smp = gdf.buffer(distance, join_style).unary_union
#convert to GeoSeries and explode to single polygons
gs = gpd.GeoSeries([smp]).explode()
#convert to GeoDataFrame
gdf_bf = gpd.GeoDataFrame(geometry=gs, crs=gdf.crs).reset_index(drop=True)
return gdf_bf
```
How to cite
If this tool is useful to your research,
star and cite it as below:
Xiaolong Liu, & Meixiu Yu. (2020, July 26). longavailable/voronoi-diagram-for-polygons. Zenodo.
http://doi.org/10.5281/zenodo.3960407
Easily, you can import it to
Mendeley.
Changelog
v0.1.1
- First release.
v0.1.2
- Fix a FutureWarning.
v0.1.3
- Make it more robust for the less-vertice-geometry inputs. #4.
- Fix a few FutureWarnings.
v0.1.6 (Merged)
- Change as Shapely goes.
MultiPolygonis not iterable any more from Shapely 2.0. - Upload a few test data.
v0.1.7
- Enhance the applicability to geometry coordinate system (GCS). #10.
- Refactor
dropHoles()by jwardbond.
v0.1.8
By jwardbond,
Update
densify_polygons()to keep the original columns.Automate code formatting with ruff and configure it using
pyproject.toml.
Owner
- Name: Xiaolong "Bruce" Liu
- Login: longavailable
- Kind: user
- Company: Southeast University
- Repositories: 10
- Profile: https://github.com/longavailable
Citation (CITATION.cff)
cff-version: 1.2.0
message: If you use this software, please cite it using these metadata.
title: longavailable/voronoi-diagram-for-polygons
abstract: Voronoi diagram for polygons is a tool to create a Voronoi diagram also known as Thiessen polygons for polygons.
authors:
- family-names: Liu
given-names: Xiaolong
orcid: https://orcid.org/0000-0002-6603-986X
- family-names: Yu
given-names: Meixiu
orcid: https://orcid.org/0000-0001-6155-8890
type: software
version: 0.1.9
date-released: 2025-04-18
doi: 10.5281/zenodo.3960405
license: MIT
repository-code: https://github.com/longavailable/voronoi-diagram-for-polygons
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 1
- Watch event: 14
- Issue comment event: 3
- Push event: 9
- Pull request review event: 3
- Pull request event: 7
- Fork event: 2
Last Year
- Create event: 1
- Release event: 1
- Issues event: 1
- Watch event: 14
- Issue comment event: 3
- Push event: 9
- Pull request review event: 3
- Pull request event: 7
- Fork event: 2
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| longavailable | l****5@g****m | 43 |
| jwardbond | j****c@g****m | 9 |
| ImgBotApp | I****p@g****m | 1 |
| Benjamin Chrétien | 2****n | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 8
- Total pull requests: 5
- Average time to close issues: about 1 month
- Average time to close pull requests: about 22 hours
- Total issue authors: 7
- Total pull request authors: 4
- Average comments per issue: 1.25
- Average comments per pull request: 0.6
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 1
- Pull requests: 3
- Average time to close issues: about 6 hours
- Average time to close pull requests: 1 day
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 1.0
- Average comments per pull request: 1.0
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- duartejr (1)
- derekschinke (1)
- leshaved (1)
- GeorgeKontsevik (1)
- ppKrauss (1)
- jwardbond (1)
- christianayala10 (1)
Pull Request Authors
- jwardbond (4)
- bchretien (2)
- longavailable (1)
- imgbot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 347 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 9
- Total maintainers: 1
pypi.org: voronoi-diagram-for-polygons
A tool to create Voronoi diagram for polygons.
- Homepage: https://github.com/longavailable/voronoi-diagram-for-polygons
- Documentation: https://voronoi-diagram-for-polygons.readthedocs.io/
- License: MIT License
-
Latest release: 0.1.9
published 10 months ago
Rankings
Maintainers (1)
Dependencies
- geopandas *
- shapely *
- actions/checkout v3 composite
- actions/setup-python v4 composite