Trip Blog‎ > ‎

Route Map!

posted Sep 24, 2011, 6:12 AM by Paul Gareau   [ updated Sep 24, 2011, 2:31 PM ]
Hi all! I finally got around to posting a map of my route - you can find it here, or my clicking "Route" on the menu on the left. I made it using data from my GPS and it's not perfect, but it's enough to give people a general idea of my route.

Tech stuff. I wanted to use my GPS data to draw the map, mostly because I'm lazy and didn't want to do it all by hand. This ended up being a little more tricky than I thought. My GPS records a "track" for each day, and each track contains multiple track points. There are usually about a week's worth of tracks per file, since that's about how often I download the data from my GPS. So, basically what I had to work with were about 80 gpx files, each file contained multiple tracks, and each track contained multiple track points. I wanted to get just a few points from each day (three seemed to be enough) for every day of my trip, and combine them into a single track that I could import into Google Maps. The most popular software for dealing with GPS files is called gpsbabel, so this is what I used for the job. The first thing I discovered is that I had too many files for it to merge, so I used the old DOS trick "copy *.gpx all.gpx" to get one big file with all my tracks. This resulted in a file with some unnecessary tags, so I used Notepad++ to globally replace/delete the extra tags. 

The tags to be deleted are:
</gpx> Except for the last
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> Except for the first
<gpx creator="Mobile Action http://www.mobileaction.com/" version="1.0" xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> Except for the first
and anything after </gpx> at the end of the file.

Regexes: 
  • </gpx><\?xml[^>]*>
  • <gpx[^>]*>
Next I ran three gpsbabel commands to remove waypoints, simplify each track to contain only three points, merge the resulting tracks, and finally convert the file into a "language" that Google Maps can understand. Here are the commands:

gpsbabel.exe -i gpx -f all.gpx -x nuketypes,waypoints -x simplify,count=3 -o gpx -F simple.gpx
gpsbabel.exe -i gpx -f simple.gpx -x track,merge -o gpx -F simple.gpx
gpsbabel.exe -i gpx -f simple.gpx -o kml,trackdata=0,labels=0,points=0 -F simple.kml

Lastly I created a new map in Google maps and imported the "simple.kml" file.

Hope this helps people trying to do something similar!

Comments