Editing GPX Tracks
From OpenStreetMap
For a variety of reasons, you may want to modify a GPX track log before uploading it to OSM.
Warning: You should only upload raw data you collected yourself. Also, OSM is interested in the raw data, so you shouldn't edit your tracks to match what you would like to see mapped. In particular, don't edit the locations of points, just exclude bad ones and split the tracks as required.
Contents |
Reasons
- Privacy: Your GPS tracks can reveal your exact address and show when you were where. This can give people a lot of information you don't want them to have. You may want to include some area around your house and possibly modify the timestamps.
- Bad data:
- You may want to remove points where your GPS receiver had poor reception (say you were inside a building).
- Also, if you spent a while at some place, the resulting cloud of points is not that useful for mapping.
- If the receiver produced unplausible results:
- distance between trackpoints more than 500m,
- speeds higher than 300km/h lower than 1km/h (values can be computed by gpsbabel)
- Organization: You may want to split your logs into parts depending on some criteria. For instance, separate the flight log and the bus trip from the airport. This allows more accurate tagging of the uploaded logs.
Options
CourseCompacter is an online application that reads CRS and GPX files and compacts the files by eliminating excess trackpoints.
gpsbabel provides filters (see below). Some of these only work on waypoints, so you may have to convert a track to waypoints and back (gpsbabel allows this).
JOSM permits reading and writing GPX files. By converting the GPX layer to a data layer, you can edit it. There are varying reports on whether an edited GPX file still contains time data and hence produces uploadable GPX files.
Viking [1] allows visualizing, editing and uploading tracks to OSM.
RouteConverter appears to be a Windows application that can edit GPX files.
Check Perl_Scripts#osmtrackfilter and http://svn.openstreetmap.org/applications/utils/filter/ for some command line tools.
gpsman is very useful if you can see past the unusual tcl/tk user interface.
Prune allows visualisation (2D,3D,osm,Google Earth) and editing of GPX files.
Using Gpsbabel Filters
There's some more information on using gpsbabel in Making GPX Tracks.
Gpsbabel lets you filter your results. It can modify tracks, routes and waypoints, not all of the filters can handle all three dataforms, check with the gpsbabel capabilities page before trying.
The filter parameter is placed between input and output parameters and takes the format
-x <filter_name>,<filter_parameter1>,<filter_parameter2>...
Include points within radius filter
This command takes two GPX files as input and then outputs those waypoints within 5 miles of 40.75N, 119.25 W into the GPX file merge.gpx.
gpsbabel -i gpx -f way_iii.gpx -f way_rino.gpx \
-x radius,distance=5M,lat=40.75,lon=-119.25 \
-o gpx -F merge.gpx
Remove all saved tracks filter
On the Garmin units old tracks can be saved and compressed. These tracks will always be downloaded unless they are filtered. As they have no time data and are compressed they also cause issues in JOSM when trying to geotag images. The following filter will only keep the tracks with ACTIVE in the title.
-x track,name="ACTIVE *"
Remove duplicates and nearby points filter
To remove duplicates points use a filter of
-x duplicate,location
To remove points that are closer than 5 meters to the proceding point use a filter of
-x position,distance=5m
Arc filter
You can convert a track log to a GPSBabel arc file and then filter waypoints based on their proximity to that 'arc' or route by using the '-x arc filter'.
Simplifying tracks
It's very easy to use gpsbabel to simplify track just this will reduce your track to 400 points, depending on your track this will not affect the accuracy much. E.g. on my biking trips the GPS captures 2 points/s I was able to simplify 8000 points to 400 or even 100 without much effect.
gpsbabel -i gpx -f way_iii.gpx \
-x simplify,count=400 \
-o gpx -F merge.gpx
Another option is to use crosstrack error filter. It discards points that are close enough to the line drawn between two points adjacent to them, so the overall track's shape is not disturbed too much. If we treat simplifying tracks as a compression process, then the above example makes the track fit into specified size while the command below preserves its quality regardless of the size. Points will be removed if they are no farther than 1 metre (0.001 of kilometre) from the track.
gpsbabel -i gpx -f way_iv.gpx \
-x simplify,crosstrack,error=0.001k \
-o gpx -F merge.gpx
You can also use Potlatch to simplify a track. Upload it to OSM, then click the "edit" link next to the uploaded track (not the edit tab at the top of the page), and click "Track" when Potlatch opens.
Remove unreliable points filter
-x discard,hdop=4
Time filters
Only include data recorded after 2008-07-23 20:00
gpsbabel -t -w -i garmin -f /dev/ttyUSB0 -x track,start=2008072320 -o gpx -F waypoint.gpx

