Metadata-Version: 2.0
Name: visvalingamwyatt
Version: 0.1.0
Summary: Simplify geometries with the Visvalingam-Wyatt algorithm
Home-page: https://github.com/fitnr/visvalingamwyatt
Author: fitnr
Author-email: contact@fakeisthenewreal.org
License: MIT
Keywords: gis
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Operating System :: OS Independent
Requires-Dist: numpy (>=1.8,<2)
Provides-Extra: cli
Requires-Dist: Fiona (>=1.6.2,<2); extra == 'cli'

Visvalingam-Wyatt
=================

A Python implementation of the Visvalingam-Wyatt line simplification
algorithm.

This implementation is due to `Eliot
Hallmark <https://github.com/Permafacture/Py-Visvalingam-Whyatt/>`__.
This release simply packages it as a Python module.

Use
---

.. code:: python

    >>> import visvalingamwyatt as vw
    >>> points = [(1, 2), (2, 3), (3, 4), ...]
    >>> vw.simplify(points)
    [(1, 2), (3, 4), ...]

Test different methods and thresholds:

.. code:: python

    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:

.. code:: python

    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 <https://github.com/Toblerity/Fiona>`__ for the
additional ability to simplify any geodata layer.

License
-------

MIT


