Simplify geometries with the Visvalingam-Wyatt algorithm
Project description
A Python implementation of the Visvalingam-Wyatt line simplification algorithm.
This implementation is due to Eliot Hallmark. This release simply packages it as a Python module.
Use
>>> import visvalingamwyatt as vw
>>> points = [(1, 2), (2, 3), (3, 4), ...]
>>> vw.simplify(points)
[(1, 2), (3, 4), ...]
Test different methods and thresholds:
simplifier = vw.Simplifier(points)
# Simplify by percentage of points to keep
simplifier.simplify('ratio', 0.50)
# Simplify by giving number of points to keep
simplifier.simplify('number', 1000)
# Simplify by giving an area threshold
simplifier.simplify('threshold', 0.01)
Shorthands for working with geo data:
import visvalingamwyatt as vw
feature = {
"properties": {"foo": "bar"},
"geometry": {
"type": "Polygon",
"coordinates": [...]
}
}
# returns a copy of the geometry, simplified (keeping 90% of points)
vw.simplify_geometry(feature['geometry'], ratio=0.90)
# returns a copy of the feature, simplified (using an area threshold)
vw.simplify_feature(feature, threshold=0.90)
The command line tools vwsimplify is available to simplify GeoJSON files:
# Simplify using a ratio of points vwsimplify --ratio 0.90 in.geojson -o simple.geojson # Simplify using the number of points to keep vwsimplify --number 1000 in.geojson -o simple.geojson # Simplify using a minimum area vwsimplify --threshold 0.001 in.geojson -o simple.geojson
Install Fiona for the additional ability to simplify any geodata layer.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
File details
Details for the file visvalingamwyatt-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: visvalingamwyatt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5443af6a12d568732850403cbcdc0c5d5c159bebfe39d7cbac78958a4f716e0 |
|
MD5 | 51b5a03959f54c280d31fa81db2c8145 |
|
BLAKE2b-256 | fe61d8dd9bba9d84e3f508c271455ae9a21bcaa89b0bea841556ea8d4ce37be8 |
File details
Details for the file visvalingamwyatt-0.1.0-py2-none-any.whl
.
File metadata
- Download URL: visvalingamwyatt-0.1.0-py2-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 461696728569240d6d66115668f458c1430677cf9e401a59aa3278e03e06b123 |
|
MD5 | 274a3124d6d7327870c24fd16e12429e |
|
BLAKE2b-256 | a11e24855d2f63f78b05efc834c6a76ef629e252cf60fb180e32bf977fe69b05 |