the further adventures of

Mike Pirnat

a leaf on the wind

« Previous Post Next Post »

When GPX Files Lie

After our May photowalk, I found that my GPS tagger had missed a bunch of data points (probably due to all the buildings and trees), so I got a copy of Dave Snyder's GPX track to use as an additional reference. At first I was excited to see a really solid track, rich with data, but was disappointed to see that it still wasn't helping--none of my photos were lining up with where I knew they should be.

Then I looked at the times on the GPX track. That started four hours before we'd started the walk.

It turns out that RunKeeper on Dave's Android phone emits timestamps that claim to be UTC, but populates them with unconverted local times. In other words--it lies.

I wrote a very quick and very, very dirty Python script to fix up all the timestamps, and that did all right for the immediate job, but it seemed like it might be useful for someone else out there, so I took some time this morning to tidy it up and make it usable as a general utility.

Using it is pretty simple; this will adjust a GPX file by +4 hours and dump it to stdout:

fix_gpx.py 4 bad_timestamps.gpx

Or perhaps we need to fix a bunch of files and want to overwrite them instead of doing the stdout donce:

fix_gpx.py -o 4 bad_timestamps.gpx really_bad.gpx super_bad.gpx

It can do negative offsets as well (in case our data points are east of UTC):

fix_gpx.py -o -- -1 east_but_still_bad.gpx

The code is up on github and I welcome pull requests for improvements or things that I'm lazy about (I am profoundly bored by packaging, so it's not PyPI-able yet).

Share and enjoy.

blog comments powered by Disqus

« Previous Post Next Post »