hiker dot rb



I mentioned before that I have some code for mapping geotagged photos on Google Maps. I've gotten a chance to wrap that up and polish it for release. May I present: hiker.rb. Thanks to a tip from an anonymous commenter my code now creates detail bubbles that include the photo rather than just a link to it. You can see a couple examples of it.

Unfortunately the process of going from a set of photos and a GPS tracks file to a KML file (which is what Google Maps reads) is somewhat involved. First there's the fact that no mainstream GPS manufacturer uses a sane format. You need a program called gpsbabel to do the conversion into the GPX format. Say you've got a saved GPS tracks from Magellan GPS that you took on your hike called myhike.log and your photos from the hike in a directory called hike_photos.

 $ gpsbabel -i magellan -o gpx myhike.log myhike.gpx 

Once you've got the GPX file, you can use gpscorrelate to write the coordinate metadata onto the photo files. This program uses the GPX file to figure out where you were at a given time and then for each photo makes a best guess that it writes to the photo file.

 $ gpscorrelate -g myhike.gpx hike_photos/* 

The one caveat at this point is that often your GPS device and your camera will be set to different time zones. If this is the case, simply add a --timeadd +8 to add 8 hours or adjust accordingly.

At this point you'll have to upload the photos to Flickr. Note that if you've already got the photos in Flickr but they don't have the coordinate metadata you'll have to re-upload them. Be sure they are tagged with something unique; you'll use Flickr tags to tell hiker.rb which to process. The last bit of setup you need is to sign up for a Flickr API key. Place the key in a file in ~/.flickr_key.

Now you're ready to run the script.

 $ ruby hiker.rb myhiketag myusername > myhike.kml 

So now you've got your shiny new hike KML file. Publish it to the web and you'll be able to view it in Google Maps by appending its URL to the Google Maps URL: http://maps.google.com/?q=http://example.com/myhike.kml

Grab the code from my repository.

 $ git svn clone svn: //dev.technomancy.us/hiker 

Or if you're still doing the centralized VC thing:

 $ svn co svn: //dev.technomancy.us/hiker 

That's all! Future revisions may automate the tiresome work of running gpsbabel and gpscorrelate, but this is how it works for now. Let me know if you run the script and have any feedback; please leave a comment.

« older | 2007-10-13T07:00:01Z | newer »