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.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for rdp_limited_edition-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3584c0445ba648fc5401e89136e4d133811641fd03d3e87d22331d84f3167afb
MD5 8fd0729ee32a0c2bb3624b6f98ce45ed
BLAKE2b-256 9afa20da492e187ea73b9421adf48662eef7170e03c0396546f9b1f0e41d30c0

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