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.1.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.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: geopolygonize-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f4194566adbe3497c3e3f5c54c316491ef250deeed5b4f0e05bb9b9bafa26704
MD5 6322659eab5ca83ee1437a736cc825d3
BLAKE2b-256 a8eade7b06366a7fd6dae2b4352ded6238c45912d2e09eb33824143689acc166

See more details on using hashes here.

File details

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

File metadata

  • Download URL: geopolygonize-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 afda5f67b67289eff8a4cbee1930667528702178cabb7b1393d7bd4327ad820c
MD5 e6dc76772df77b156cf2bc43cec7e6f3
BLAKE2b-256 41cf030fb1f2f2fb7362fbf1f884fb5f8821125cc0bb6a152e0d281cc925743e

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