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.
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.
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.
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">
<trkpt lat="40.360201774" lon="116.013833955">
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.