I am working with GPS track files (list of X and Y coordinates). I have tracks with a high sampling rate and want to downsample the track for easier handling.

The obvious way would be to create a new list of points, and to keep only (for example) every 100th point of the track. The problem is that this could remove important extremes, such as curves.

Do you know algorithms, which allow to downsample the two dimensional array, while keeping the extremes (and dropping datapoints without much value, such as points which are in a straight line).

It would be great if there would be a solution in python, but I'm gratefule for all kind of help.


  • $\begingroup$ You could calculate a distance metric and keep only the n points with maximal distance. $\endgroup$ Sep 20 '18 at 13:33

Ramer–Douglas–Peucker algorithm sounds like what you are looking for!


This algorithm allows you to simplify a sampled path. Basically, given a maximum allowed error, it proceeds by evaluating if a sequence of samples can be represented well enough (wrt the error) with a straight line between the first and the last point: if all the points in-between them falls under the error, all of them can be removed, otherwise it tries again with a shorter sequence.

This means that, setting a reasonable error value, on a straight road it will go for strong downsampling, while on an hairpin turn it may even decide to not downsample at all.

It seems there is a ready-to-go implementation in python https://github.com/fhirschmann/rdp

Eventually, you may find this talk from EuroPython 2016, about "Handling GPS Data with Python" by F. Wilhelm (I learn about the algorithm from this)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.