Skip to main content

Douglas-Peucker line simplification

Project description

DoPe

Douglas-Peucker line simplification (data reduction).

Reduces the number of points in a dataset, while preserving its most striking features.

The resulting dataset is a subset of the original dataset.

Similar algorithms are used e.g. when zooming on a geographical map. However, this type of algoithm is also useful for general data reduction, as an alternative to conventional filtering.

Currently we only offer a recursive implementation (depth-first), which may not be the most efficient. An iterative implementation may follow (breadth-first).

Installation

Normal installation:

pip install dope

With plot support (adds matplotlib):

pip install dope[plot]

With development tools:

pip install dope[dev]

Example

from dope import DoPeR
import numpy

data_original = [
    [0, 0], [1, -1], [2, 2], [3, 0], [4, 0], [5, -1], [6, 1], [7, 0]
]

dp = DoPeR(data=data_original)

# either use epsilon threshold (i.e. max. error w.r.t. normalized data)
data_simplified_eps = dp.simplify(epsilon=0.2)

# or use maximum recursion depth
data_simplified_depth = dp.simplify(max_depth=4)

# compare original data and simplified data in a plot
dp.plot()

Also see examples in tests.

References:

Douglas DH, Peucker TK. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartographica: the international journal for geographic information and geovisualization. 1973 Dec 1;10(2):112-22.

Project details


Download files

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

Source Distribution

dopelines-0.1.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

dopelines-0.1.0-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

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