Skip to main content

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

visvalingamwyatt-0.1.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

visvalingamwyatt-0.1.1-py2-none-any.whl (15.2 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for visvalingamwyatt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c179b45528a45586357fdbf7ceace272eed196c3c0dbf3808ce6a2cafa3bb6b9
MD5 ea4955a93738180439a69e1caf97468a
BLAKE2b-256 e0471f9dc9d2444187850f4785694477197efe08cc717d7d7f9472280d22b3ee

See more details on using hashes here.

File details

Details for the file visvalingamwyatt-0.1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for visvalingamwyatt-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 ea7a9055f87d0408155fa272f82fc4de98d426b40be2a75dc67f66a499ecd1d4
MD5 c3cbcd647e286d15322f135bbedd8268
BLAKE2b-256 2fa5f3f5c0ed79debe55f4777898d7651a9bc870898e9827c77634bca0624afc

See more details on using hashes here.

Supported by

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