/rdp-algo

Ramer-Douglas-Peuker python implementation

Primary LanguagePythonMIT LicenseMIT

Ramer-Douglas-Peucker

Ramer-Douglas-Peucker python implementation.

Installation

pip install pyrdp

Usage

The rdp function supports both lists and numpy arrays of arbitrary dimensions.

>>> from pyrdp import rdp
>>> rdp([[0,0],[1,1],[2,0]], epsilon=1)
[[0,0],[2,0]]
>>> import numpy as np
>>> from pyrdp import rdp
>>> rdp(np.array([[0,0],[1,1],[2,0]]), epsilon=1)
array([[0,0],[2,0]])

If you specify return_mask=True the function will return a mask of the points that were kept.

>>> import numpy as np
>>> from pyrdp import rdp
>>> rdp(np.array([[0,0],[1,1],[2,0]]), epsilon=1)
array([True, False, True])