Convert geographic rasters into simplified polygons
Project description
Geopolygonize
Convert geographic rasters into simplified polygons. Given an input raster file, this tool produces a shapefile representation of the raster that simplifies out pixelation. It also maintains shapes' relations to one another such that the output is guaranteed to have no gaps.
Install
pip install geopolygonize
Quickstart
To convert a raster to simplified polygons, run:
python geopolygonize.py --input-file="data/input.tif" --output-file="data/output.shp"
Algorithm and options
Most existing methods for polygon simplification such as the Douglas–Peucker simplification algorithm or concave hulls operate on a single polygon at a time. This presents a problem when run on a collection of polygons that fit together perfectly–simplifying each polygon separately will introduce unpredictable gaps. Our algorithm takes an approach similar to TopoJSON. It identifies the boundaries shared between polygons, simplifies those boundaries, then assigns the simplified boundaries back to the polygons. This results in simplified polygons that fit perfectly together without any gaps.
We also perform a cleanup step before converting to vectors that removes any isolated pixels of a particular value. This helps create a more visually cohesive albeit slightly less accurate output. You can specify the minimum size a collection of pixels must be to keep in the raster with --min-blob-size. Collections of pixels below this size will be stripped out and filled in with the pixels around them.
To speed up the computation, we first split the raster into tiles (whose size in pixels can be specified with --tile-size in the script), then process the tiles parallel. You can adjust the number of workers that are spawned with --workers.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geopolygonize-0.1.0.tar.gz.
File metadata
- Download URL: geopolygonize-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba1ff5731ff699c5a0ac15f529cff05f74f1b2bfaf6a6a889ebac53d008ed67e
|
|
| MD5 |
f225849bb0cbe22858edfcac77b06823
|
|
| BLAKE2b-256 |
c72f47449b0faaee0dbb31cb80cd5408760a0d3ee1a8ea2bcf3cd38283f5d23d
|
File details
Details for the file geopolygonize-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geopolygonize-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d21d295329ded01a5fdfbe85c61312aa92f9efb960c82201fc3b9a7772080f2
|
|
| MD5 |
608ae1a0fe00f6da8c7bb747414ea0b8
|
|
| BLAKE2b-256 |
c56cdbe556e62785fd688d9afc5319e288963674a259eb7aa44e01db38859c7d
|