GPS Visualizer

« GPS Visualizer Tutorials

Tutorial: Smoothing & Simplifying Tracks

There are two options in GPS Visualizer's mapping and file conversion input forms that allow you to "simplify" your tracks: Max. points per track (trk_simplify) and trackpoint distance threshold (trk_distance_threshold). They both reduce the number of trackpoints (while preserving time stamps and other information), but in very different ways.

Max. points per track

GPS Visualizer's "max. points per track" option, which has been available since 2006, reduces the number of points in a track by passing the track through GPSBabel and asking GPSBabel's simplify filter to remove the most redundant points, based on how much those removals will affect the overall shape of the track (in technical terms, it measures "cross-track error").

For example, here's a track with 10 points:
If we set the maximum number of points to 6, four of the points on the "straightaway" sections of the track are removed, leaving us with a modified track that looks very much like the original:

So far, so good; the "max. points" setting works well on relatively clean data, and it's very useful if you need to reduce the number of points in a track because your GPS device has a specific limit. (For example, Garmin's older GPSMap units only allow 500 points per track.) But now let's look at an example where the "preserve the shape of the track" method doesn't work as well...

Here's another hypothetical track, this time with 11 points. As you can see, something weird is happening between point #3 and point #8; if this was a GPS track, it's likely that the person recording the track stopped for a minute, and the GPS signal "wandered around" while he or she stood still. (Of course, it's also possible that this jagged line reflects reality, but let's assume for now that it's just the result of unwanted artifacts in the raw data.)
If we set the maximum number of points to 6, the jaggedness is preserved, because the simplification filter thought that all those sharp angles were important! This is not an ideal result.

Obviously, we need another approach to cleaning up track data automatically. Which brings us to...

Trackpoint distance threshold

The newer "trackpoint distance threshold" filter examines each point in a track, in order, and discards every trackpoint that is not at least X distance from the last non-discarded point; you get to choose the value of X. If you don't supply a distance unit (feet, miles, etc.), the threshold given is assumed to be in meters.

Here's a track with seven points; it should start eastward and then simply bend to the southeast, but the dreaded GPS "jaggies" have made an appearance. If we add up the raw distances between all seven points, it comes to 17 meters.
So we'll set the trackpoint distance threshold to 4 meters; this means that points are only allowed to stay in the track if they're at least 4m away from the last valid point. The first point is always considered valid, so A gets to stay. The distance from A to B is 5 meters, so B is OK too. But C is only 2m away from B, so it needs to be removed. D is 4m from C, which would have been enough to get past our threshold, but we deleted C; D's distance from the last valid point (B) is only 2.95m, so it comes out too. E is also too close to B. Finally, we come to point F, which is 4.82 meters from point B; F will not be removed, and if there were any more trackpoints, they would be evaluated based on their distance from F.
We're left with only three points, but they more accurately reflect the path that was traveled... and perhaps more importantly, the distance that was traveled. The distance measurement based on the raw data was 17 meters, but now we see that it was really about 10 meters. That's going to make a difference when calculating slope or creating elevation profiles.

By the way, here's what happens if we apply an appropriate distance threshold filter to the jagged second example in the "Max. points per track" section at the top of this page; it's a much better result:


Choosing a threshold

The question is, what distance should you use as a trackpoint distance threshold? That depends on a few things. Obviously, with a very small threshold, lots of detail will be preserved, but so will some of the artifacts. But a threshold that's too big will smooth things out too much and cause you to lose sharp corners and switchbacks. Speed is an important consideration; if the track was recorded in a car or on a bicycle, a larger threshold is appropriate, because the trackpoints will typically be farther apart. (In fact, tracks recorded in a car probably need very little filtering anyway, unless there were a lot of stops that may have produced GPS "wandering." Also, many GPS units are already set up to only record points once a certain distance has been traveled anyway; if that's the case, GPS Visualizer's filter is redundant.)

The following animated graphic is a real-world demonstration of the effects of different trackpoint thresholds on two different tracks that were recorded on hiking trails. (Note that the scale of the two halves of the graphic is slightly different; the left side is zoomed in one step closer.) The "knots" in the track occurred when the hiker stopped to rest or take photos; obviously we want those knots unraveled.

[trackpoint distance threshold demonstration]

But how much smoothing is too much? On the right side, near the center, there is a sharp rightward-pointing angle that really is part of the trail; at threshold=8m, that corner disappears, so the best choice for that track might be about 4m. On the left side, however, there's a sharp zigzag in the upper-right part of the map that is still there at threshold=4m; maybe something like 8m would be a better choice there. On both sides, we can see that a threshold of 1m or 2m can't possibly hurt anything, whereas anything above 16m starts to look ridiculous. (Your threshold doesn't have to be a power of 2; these are just examples.)

The full Google Maps from the example above are available for you to explore: left side, right side. The reduced number of points and recalculated distances are listed in the track legends.

Combining the two track filters

Yes, the two methods of track simplification can be used together. The distance threshold is applied first, and the angle-based point reduction (maximum number of points) is applied second. So you can use a distance filter to clean up the GPS artifacts, and limit the number of points in the output, all in one fell swoop.

[Return to top]

[Return to the Tutorials index]

Return to the main GPS Visualizer page