Visvalingam-Wyatt
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), ...]
Points may be any Sequence-like object that (list, tuple, a custom class that exposes an __iter__ method).
Test different methods and thresholds:
simplifier = vw.Simplifier(points)
# Simplify by percentage of points to keep
simplifier.simplify(ratio=0.5)
# Simplify by giving number of points to keep
simplifier.simplify(number=1000)
# Simplify by giving an area threshold (in the units of the data)
simplifier.simplify(threshold=0.01)
Shorthands for working with geodata:
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 tool 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
Metadata
Release files for visvalingamwyatt 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| visvalingamwyatt-0.3.0.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| visvalingamwyatt-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.9 kB
Release files / visvalingamwyatt-0.3.0.tar.gz
| Download URL | visvalingamwyatt-0.3.0.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
517399516b11474615d987515c76e00592f6672dc018c4799e7cc37e6d53e3b7
|
|
BLAKE2b-256 checksum How to use checksums |
6c0d2468d8bd948b4b2ae7d2f5d6d859d217de1dd19bf9b579c631711a8136d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / visvalingamwyatt-0.3.0-py3-none-any.whl
| Download URL | visvalingamwyatt-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5db733dcda754aae3f2bba04b2ead8f0e3c0e30f65f3fae2c9d9d6c1295e017
|
|
BLAKE2b-256 checksum How to use checksums |
d949911423a0fce38bc719dc394d2b10ff8bd6d38af6462fb89b86ff94c35c1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|