Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Release History

Release History

This version
History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
visvalingamwyatt-0.1.1-py2-none-any.whl (15.2 kB) Copy SHA256 Checksum SHA256 py2 Wheel Jan 21, 2016
visvalingamwyatt-0.1.1-py3-none-any.whl (15.2 kB) Copy SHA256 Checksum SHA256 py3 Wheel Jan 21, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting