This repository contains a high-performance Python library, implemented in Rust, for the Ramer-Douglas-Peucker algorithm.
The Ramer–Douglas–Peucker algorithm is an algorithm that decimates a curve composed of line segments to a similar curve with fewer points [1].
pip install rdp2Works with lists, tuples, numpy ndarrays and any mixture of the three types, e.g. list[tuple(float, float)].
from rdp2 import rdp
rdp([[1, 1], [2, 2], [3, 3], [4, 4]], 1.0)
# result: [[1, 1], [4, 4]]from rdp2 import rdp
rdp(((1, 1), (2, 2), (3, 3), (4, 4)), 1.0)
# result: [[1, 1], [4, 4]]import numpy as np
from rdp2 import rdp
rdp(np.array([1, 1, 2, 2, 3, 3, 4, 4]).reshape(4, 2), 0.5)
# result: array([[1, 1], [4, 4]])This project is heavily inspired by the work of Fabian Hirschmann. He originally published the first rdp package, which I came across when looking for an implementation of the RDP algorithm.
The bench.py script provides a runtime comparison between Hirschmann's rdp and this repos rdp2.
This project is licensed under the GPLv3 License.


