Skip to main content

Ramer-Douglas-Peucker algorithm implementation with remaining points limit

Project description

rdp-limited-edition

PyPI - Version PyPI - Python Version


Table of Contents

About

Yet another Ramer-Douglas-Peucker algorithm implementation (line simplification). But this one is special! It allows to additionally define the maximum number of points to retain. This means the algorithm stops to select additional points as soon as the maximum number ot points is reached although there would be more points outside of the tolerance band. To that, a negative tolerance allows to always get a defined number of points which are chosen accoring to the RDP algorithm. To provide this feature, no recursion is used.

Pure numpy. Hence the performance is not as fast as C/Rust implementations like simplify or similar (approx. TODO times slower).

Installation

pip install rdp-limited-edition

Usage

import numpy as np
from rdp_limited_edition import rdp_limed

x = np.arange(360.0) * np.pi / 180.0
y = np.sin(x)

# let the tolerance be decisive
print(rdp_limed(x, y, max_points=x.shape[0], tolerance=0.005))

# get defined number of points
print(rdp_limed(x, y, max_points=10, tolerance=-1))

# or use both
print(rdp_limed(x, y, max_points=10, tolerance=0.1))
print(rdp_limed(x, y, max_points=10, tolerance=0.001))

Related Publications

  • D. H. Douglas and T. K. Peucker, “Algorithms for the reduction of the number of points required to represent a digitised line or its caricature,” The Canadian Cartographer, vol. 10, no. 2, pp. 112–122, Dec. 1973.

License

rdp-limited-edition is distributed under the terms of the MIT license.

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 Distribution

rdp_limited_edition-0.3.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file rdp_limited_edition-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rdp_limited_edition-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93beb354bec0302fefc1899621ebc48862e83295676db967ebedc5194b4c2372
MD5 0b2e3270628d18f307262eb37f88b34a
BLAKE2b-256 9d98fd92f4d782d549ab2f668e75ccf6ac55f7b63ed8b8a1ce580d67e43d19e9

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