Skip to main content

Douglas-Peucker line simplification

Project description

DoPe

Douglas-Peucker line simplification (data reduction).

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

The resulting dataset is a subset of the original dataset.

Although line simplification is typically used for geographical data, e.g. when zooming a digital map (see e.g. Django's GEOSGeometry.simplify() based on GEOS), this type of algorithm can also be applied to general data reduction problems, as an alternative (or addition) to conventional filtering or subsampling. Some examples:

  • creating miniature data plots
  • pre-processing time-series data for feature detection (e.g. peak detection)

Installation

Normal installation:

pip install dopelines

With plot support (adds matplotlib):

pip install dopelines[plot]

With development tools:

pip install dopelines[dev]

Note: The PyPi project is called dopelines instead of dope, because PyPi would not let us create a project named dope, even though the name appears to be available.

Example

from dope import DoPeR

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

dp = DoPeR(data=data_original)

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

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

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

Example line simplification plot.

Also see examples in tests.

Limitations

Currently we only offer a recursive implementation (depth-first), which is intuitive, but may not be the most efficient solution. An iterative implementation is in the works (breadth-first).

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.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

dopelines-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file dopelines-0.1.1.tar.gz.

File metadata

  • Download URL: dopelines-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for dopelines-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6c6014335eb7169b5452b60954245163f70325dbc05f49192255aa9ed72118b9
MD5 b178a65c4156356f40afcdc754fe377a
BLAKE2b-256 5a1fce4cc292923c5807a7e66e75b9bc7696fa8fdb2eb7a3f47e333a472eb11a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dopelines-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for dopelines-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a32305f5dccfb28e4f2fac435c3f107bab8162e0227dd82059f4270ef6568894
MD5 18c74d7896f42b3e8eb9476f4269ca93
BLAKE2b-256 0468f0a415362fb6d2fdbef5a15a173736b0ef0bb9bf5ed7974ab0058bcb233d

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