# rdp-limited-edition
[![PyPI - Version](https://img.shields.io/pypi/v/rdp-limited-edition.svg)](https://pypi.org/project/rdp-limited-edition)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rdp-limited-edition.svg)](https://pypi.org/project/rdp-limited-edition)
-----
## Table of Contents
- [About](#about)
- [Installation](#installation)
- [Usage](#usage)
- [Related Publications](#related-publications)
- [License](#license)
## About
Yet another [Ramer-Douglas-Peucker algorithm](https://martinfleischmann.net/line-simplification-algorithms/) 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](https://numpy.org/).** Hence the performance is not as fast as C/Rust implementations like [simplify](https://pypi.org/project/simplification/) or similar (approx. TODO times slower).
## Installation
```console
pip install rdp-limited-edition
```
## Usage
```python
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](https://spdx.org/licenses/MIT.html) license.
Raw data
{
"_id": null,
"home_page": null,
"name": "rdp-limited-edition",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "line simplification, ramer-douglas-peucker, rdp, simplification",
"author": null,
"author_email": "m-birke <wesci@web.de>",
"download_url": null,
"platform": null,
"description": "# rdp-limited-edition\n\n[![PyPI - Version](https://img.shields.io/pypi/v/rdp-limited-edition.svg)](https://pypi.org/project/rdp-limited-edition)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rdp-limited-edition.svg)](https://pypi.org/project/rdp-limited-edition)\n\n-----\n\n## Table of Contents\n\n- [About](#about)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Related Publications](#related-publications)\n- [License](#license)\n\n## About\n\nYet another [Ramer-Douglas-Peucker algorithm](https://martinfleischmann.net/line-simplification-algorithms/) implementation (line simplification). **But this one is special!** It allows to additionally define the maximum number of points to retain.\nThis 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.\n\n**Pure [numpy](https://numpy.org/).** Hence the performance is not as fast as C/Rust implementations like [simplify](https://pypi.org/project/simplification/) or similar (approx. TODO times slower).\n\n## Installation\n\n```console\npip install rdp-limited-edition\n```\n\n## Usage\n\n```python\nimport numpy as np\nfrom rdp_limited_edition import rdp_limed\n\nx = np.arange(360.0) * np.pi / 180.0\ny = np.sin(x)\n\n# let the tolerance be decisive\nprint(rdp_limed(x, y, max_points=x.shape[0], tolerance=0.005))\n\n# get defined number of points\nprint(rdp_limed(x, y, max_points=10, tolerance=-1))\n\n# or use both\nprint(rdp_limed(x, y, max_points=10, tolerance=0.1))\nprint(rdp_limed(x, y, max_points=10, tolerance=0.001))\n```\n\n## Related Publications\n\n- D. H. Douglas and T. K. Peucker, \u201cAlgorithms for the reduction of the number of points required to represent a digitised line or its caricature,\u201d The Canadian Cartographer, vol. 10, no. 2, pp. 112\u2013122, Dec. 1973.\n\n## License\n\n`rdp-limited-edition` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Ramer-Douglas-Peucker algorithm implementation with remaining points limit",
"version": "0.3.1",
"project_urls": {
"Documentation": "https://github.com/m-birke/rdp-limited-edition#readme",
"Issues": "https://github.com/m-birke/rdp-limited-edition/issues",
"Source": "https://github.com/m-birke/rdp-limited-edition"
},
"split_keywords": [
"line simplification",
" ramer-douglas-peucker",
" rdp",
" simplification"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c8e044d9e2dbcb38520f70219238a1ad64705e1111ff3db04b6a0943fbbaef8b",
"md5": "4dab473e6a7a25afe6c7c54e285cdd95",
"sha256": "1345f37b1a6077117c13446ced2aeccedaa94e83bd236440224a11bb624d167d"
},
"downloads": -1,
"filename": "rdp_limited_edition-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4dab473e6a7a25afe6c7c54e285cdd95",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5095,
"upload_time": "2024-11-13T16:39:32",
"upload_time_iso_8601": "2024-11-13T16:39:32.519091Z",
"url": "https://files.pythonhosted.org/packages/c8/e0/44d9e2dbcb38520f70219238a1ad64705e1111ff3db04b6a0943fbbaef8b/rdp_limited_edition-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-13 16:39:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "m-birke",
"github_project": "rdp-limited-edition#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "rdp-limited-edition"
}