Developing a program for reducing the size of gpx-tracks


I know this is a bit OT, but as many of you are using gpx-files I think the OSM-forum is the best place for this.

I’m developing a program for reducing the number of points on gpx-tracks. Of course there are already many programs that can do this, but it’s hard to find one for Linux that doesn’t just delete every 2. point, decreasing the quality of the track enormously (please correct me if I’m wrong).
My program (in Java, so it will run on most operating systems) uses the Douglas-Peucker algorithm (see for details) to decide which points can be deleted.
There are still a lot of bugs, but it can already be used to reduce the size of gpx-files, as long as there aren’t any “” or “” tags.

If you like to test it, please download it from
I’m looking forward to your feedback!

What about removing whitespaces and gzipping it. This decreases the file-size enourmously, as seen at osm-files…

Thank you for testing!

Well, I could remove whitespaces (in fact, I had to do some extra work to include whitespaces and newlines), but for developing and testing, being able to read the file is very useful; if I’d remove all whitespaces the whole thing would no longer be human-readable (have you ever tried to understand a gpx-file with only one line?).
A gzipped file can’t be used in other programs; you’d first have to unzip it, so why should I gzip the file?

Maybe I could include an option to set whether the output file should be human-readable or not.
I’ll try it…

I just updatet the files, now there are 3 more possible options. Now you can set whether a the output should be human-readable (structured, line breaks and whitespaces) or not (no line breaks, no whitespaces). You also can set a default.

a gzipped file can be used by JOSM and you can upload it also to OSM for using it in Potlatch.

A nice program for reducing long gps tracks (.gpx) for usage in a Garmin Vista HCx without loading the track as ACTIVE LOG.

It is working quite good for me (in linux), thank you,


Thanks for testing! :slight_smile:
Do you think it’s okay for everyday use?

I’ve tested the program on Windows now, and so far there were no problems. :slight_smile:

Sorry, I didn’t know this. But actually, my program should just be able to reduce the number of points on a track, e.g. to show tracks on website (small files) or to use them in programs that are limited to a certain number of points. I think uploading a reduced file to OSM isn’t that good, because you use the track to draw maps, so you need more exact traces.


For me it is ok. I used a perl script to reduce the trackpoints of a gpx file up to now, because my Etrex Vista HCx can only store gpx files up to 500 trackpoints (as ACTIVE LOG up to 10000, but then the recording of tracks is blocked).

With your program the track is near the original track and that is important for reduced tracks.

Thank you again,


And you can also serve it this way.
You could add an encoding line to your Apache mod_rewrite (or other servers), so that it can be sent gzipped, but is opened in the browser (the map, …) as a usual gpx file:

AddType “text/xml” .gpxz
AddEncoding x-gzip .gpxz

Now I added an option for gzipping the output file. It seems to work and when I leave out whitespaces at the same time, I get a 5KiB file (original: 190KiB) instead of 25KiB (without gzipping).
I also corrected the line separator (it’s chosen automatically now, instead of using “\n”, which doesn’t work on Windows).

Just to add about the original comment “but it’s hard to find one for Linux that doesn’t just delete every 2 point”

I’m using gpsbabel with the crosstrack filter :

As I understand the Douglas Peucker algorithm, it’s exactly what is described in the gpsbabel filter.
Plus you are able not only to give the number of points wanted but also the max lenght distance error introduced by removing a point, wich is more convenient when your gpx track as an unknown shape