OpenStreetMap logo OpenStreetMap

Average tracks: drawing a "line of best fit" automatically

Posted by Guttorm Flatabø on 26 September 2011 in English. Last updated on 13 October 2011.

Do you have many not so accurate tracks from the same hike, drive or route lying around? Would you like to take advantage of all that data and merge them into a “line of best fit” / average track?

Try the average tracks script.

The accuracy of the points in a single GPS trace may be out by several meters. This depends on lots of factors such as the positions of the satellites when the trace was taken, tree cover, proximity to nearby buildings, position of the GPS unit relative to the center of the road etc. If many traces are taken for the same road, then the effect of errors in any one trace will have a much smaller impact on the average position of these traces. (from "Good practice" on the OpenStreetMap wiki).

Made by Michiel Faber, and given a home and documentation by Guttorm Flatabø, this is a first step, using R. With increased use and contributors we could soon have something more functional. The script comes with no warranty, use at your own risk, and please report bugs, improvements etc. on github, or directly to Michiel or Guttorm (using OSM messaging).

The work on this was done in connection with the Northern Periphery Program project Tourist Guide for the Northern Periphery.

Location: 61.181, 6.881


Comment from z-dude on 28 September 2011 at 06:03

Does it work with more than 2 tracks? For two tracks, you have situations where one track is off due to a reflection off of a cliff face, so you're sometimes better off by picking the non reflected track.

Comment from Guttorm Flatabø on 28 September 2011 at 06:55

Yes, I don't know if there is a theoretical limit, but the script isn't very fast so I guess there is some practical limit if it has to process thousands and thousands of points. There's a demonstration directory that has six tracks, which works fine.

Comment from z-dude on 28 September 2011 at 07:05


Log in to leave a comment