Astute observers (or people I told about it) will have noticed that in our gallery of China pictures, clicking the links on the left “View Album on a Map” and “View in Google Earth” do cool stuff.
I promised I would write about how I did that, so I will. There are obviously other ways to geotag photos, but this is what I did.
The Gear
Before the trip, I had the realization that I didn’t have to get some kind of GPS receiver that connected to my camera: any GPS data was enough, as long as it was timestamped. The photos I take are timestamped, so if the GPS data is too, I can connect the two and figure out where pictures were taken (assuming the GPS and camera are close to each other).
So, before the trip, I picked up a eTrex Venture HC. It claimed to be high-sensitivity, so that sounded good. Also, it was on the cheaper side of GPS receivers and it records the track data I needed.
I had the GPS on a lot over the trip, and I think I ran through 4 pairs of AA batteries the whole time. That’s quite reasonable to my mind.
The cameras were my Rebel XT and Kat’s SD800. Basically, it can be any Digital camera with its clock set reasonably accurately.
On the Trip
When we were about to arrive somewhere, all I had to do was flip on the GPS and throw it back in my camera bag. Then, take some pictures. When leaving, turn the GPS off.
The GPS records its position (“tracks”) until I turn it off. (It’s important with a Garmin GPS to not “save” the track: that throws away critical time info.) Just turn it off when done.
Processing
The data can be pulled off the GPS to a GPX file with its own software or GPSBabel. Photos come off the camera in the usual fashion.
I couldn’t find anything I liked to get the GPS data and the camera time stamps together, so I did what I always do in these situations: I started writing Python. The job was basically to read the GPS data, read the timestamps from JPEG files, interpolate the GPS data, and write the position data back to the JPEG.
I threw what I have on SourceForge as “Geotag Merge“. I haven’t “released” it yet, so you have to grab the Subversion repository if you want to play. Sooner or later, I’ll find some best-practices for packaging Python-based applications and I’ll do a beta release.
I added the Gallery2 GPS module to my gallery to make it all work.
An Example?
Okay, look at this picture which, according to its time stamp, was taken at 2009-04-19 14:20:08 (Beijing time) = 2009-04-19 06:20:08 UTC. Looking in the GPX file extracted from the GPS, I see these entries:
<trkpt lat="40.360190626" lon="116.013850048"> <ele>829.274414</ele> <time>2009-04-19T06:19:48Z</time> </trkpt> <trkpt lat="40.360201774" lon="116.013833955"> <ele>829.274414</ele> <time>2009-04-19T06:20:11Z</time> </trkpt>
Like all good XML, this is minimally-human-readable: two observations separated by 23 seconds, with latitude, longitude, time, and elevation.
So, I deduce that the picture was taken in between these locations (and in fact very close to the second). A quick linear interpolation, and we decide that the picture was taken at 40°21’36.72″N 116°0’49.81″E (and 829.27 metres above sea level). This is then written back as part of the image’s EXIF tag, and it can be picked up by any geotagging-aware photo viewer.
May 16th, 2009 at 4:13 am
Now I see that the solution is to hack the GPS satellites and trick the GPS receiver into recording the payload of my choice, and there we have automatic insertion of EXIF exploits.
May 16th, 2009 at 4:16 am
Oh yeah, I should mention my comment on the actual post. Cool read. It answers the question I had when I first saw that they were geotagged.
I was also wondering, since nobody has been able to answer my question thus far, does the iPhone geotag it’s photos? It has a camera and a GPS receiver, one would assume a logical pairing.
May 16th, 2009 at 9:34 am
I was just about to say no to the iPhone thing, but I thought I’d better check. Much to my surprise, a couple pics I have from Kat’s iPhone are geotagged!
On closer inspection, they are about a kilometer away from the true phone location: I assume that means they used the cell tower for location instead of GPS. That makes sense: the GPS is probably kept off to save battery, and towers is all it had.
There may be a way to force the GPS on to increase the accuracy, but I don’t know what that is.
May 16th, 2009 at 4:54 pm
This is awesome. Out of curiosity, did you happen to try the geo-tagging in digiKam? They claim to be able to merge images and GPS data. If they didn’t do something you wanted to do, maybe you should consider submitting your code to them…. You guys took great photos.
May 18th, 2009 at 9:29 am
Hrm… digiKam does appear to do the same thing, more-or-less. It comes up with slightly different numbers: asking why might be interesting.
Maybe what I really need to start is a page of programs that do this kind of thing.