https://github.com/ekspla/douglas-peucker_n
Reduce gpx track points using Douglas-Peucker N
https://github.com/ekspla/douglas-peucker_n
douglas-peucker douglas-peucker-n gpx python
Last synced: 3 months ago
JSON representation
Reduce gpx track points using Douglas-Peucker N
- Host: GitHub
- URL: https://github.com/ekspla/douglas-peucker_n
- Owner: ekspla
- License: mit
- Created: 2023-05-18T02:37:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-21T06:23:08.000Z (almost 3 years ago)
- Last Synced: 2025-01-14T06:47:39.461Z (over 1 year ago)
- Topics: douglas-peucker, douglas-peucker-n, gpx, python
- Language: Python
- Homepage:
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Douglas-Peucker_N
**Reduce gpx track points to a target number of points** by using [Douglas-Peucker N algorithm](https://psimpl.sourceforge.net/douglas-peucker.html).
May 2023, a quick [python port](https://github.com/ekspla/Douglas-Peucker_N) by ekspla.
Requires [gpxpy](https://github.com/tkrajina/gpxpy) or [lxml](https://pypi.org/project/lxml/).
[Original version written in JavaScript](https://github.com/330k/gpx_tools) by 330k.
## Introduction
This is a faster algorithm to reduce size of a track as compared to [simplify--crosstrack in gpsbabel](https://www.gpsbabel.org/htmldoc-1.8.0/filter_simplify.html).
I found it useful for processing tracks/routes before installing them into small navigation devices.
Processing time was measured using my core i5 (gen4) PC with CPython 3.9 and compared with those of gpsbabel.
It took less than 1 sec to reduce 78252 of trackpoints ([a sample file in 330k's web site](https://github.com/330k/gpx_tools)) to 2000 points, surprisingly faster than 23 sec with gpsbabel.
## Coordinate transformations used in the scripts
- `reduce_points.py`
(x, y) = Mercator_projection **(latitude, longitude)**; assuming sphere.
- `reduce_points_3d.py`
(x, y, z) = Cartesian **(latitude, longitude, altitude)**; assuming ellipsoid.
This script may be useful if the track/route passes a hill top.
- `reduce_points_2dt.py`
(x, y) = Mercator_projection **(latitude, longitude)**; assuming sphere.
z = **time** * Average_speed
This script may be useful in processing real gps tracks **with timestamps**.
## How to use
**An example to process tracks** is shown in **reduce_points()**. For routes/waypoints, modify the codes in that function.
If you want to use them with **lxml**, examples are shown in **./lxml**.
## Reference
[1] https://www.gpsbabel.org/htmldoc-1.8.0/filter_simplify.html
[2] https://github.com/330k/gpx_tools
[3] https://330k.github.io/line_simplify_demo/gpx_visual_simplify.html