Ramer-Douglas-Peucker algorithm implementation with remaining points limit
Project description
rdp-limited-edition
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
Built Distribution
File details
Details for the file rdp_limited_edition-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: rdp_limited_edition-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.25.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1345f37b1a6077117c13446ced2aeccedaa94e83bd236440224a11bb624d167d |
|
MD5 | 4dab473e6a7a25afe6c7c54e285cdd95 |
|
BLAKE2b-256 | c8e044d9e2dbcb38520f70219238a1ad64705e1111ff3db04b6a0943fbbaef8b |