Skip to main content

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.

Algorithm

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.

Install

pip install geopolygonize

Quickstart

To convert a raster to simplified polygons, run:

geopolygonize --input-file="data/input.tif" --output-file="data/output.shp"

CLI Options

--min-blob-size

Optional raster preprocessing step to remove pixels that are not connected to neighboring pixels with the same value. This value dictates the minimum number of pixels of the same value each must be connected to in order to be kept. Pixels in blobs smaller than this value will be removed and filled with the most common pixel value surrounding it.

--tile-size

The polygonization process can be run in parallel to speed up the computation. To prepare to process in parallel, the raster is cut into square tiles of this number of pixels.

--workers

Number of workers that should be spawned to process tiles in parallel.

Development

Install the requirements:

pip install -r requirements.txt

# TODO: API docs

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

geopolygonize-0.1.2.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geopolygonize-0.1.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file geopolygonize-0.1.2.tar.gz.

File metadata

  • Download URL: geopolygonize-0.1.2.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for geopolygonize-0.1.2.tar.gz
Algorithm Hash digest
SHA256 206a13eeb68c97f2018d6b434510caa4cb3d242baef176915be184e3acce4dd0
MD5 7a7637d779870df5e9132bd9baf21f8d
BLAKE2b-256 2e9a50c8d5f3e30546d5e8ec40144d24a44740a260e622ccfe44ae8623558b3f

See more details on using hashes here.

File details

Details for the file geopolygonize-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: geopolygonize-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for geopolygonize-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2d9f2c513f221fa9681cc16ef1b6f19a2666634414121d64603106cda3b95b9e
MD5 e180a47cfeada5252dcdc16d7fed370d
BLAKE2b-256 ee607c8bb72046c251f6da7eb231d95e2b0e55bc7ce91daf8167b194bbb63871

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page