Tatsuhiko Miyagawa's Blog


August 10, 2013

Link: miyagawa/kml2xmp

Decodes kml for track info, and then locate the position for each photo taken, and creates .xml sidecar files next to the raw file, when it doesn’t exist already. kml2xmp uses sips command (comes with Mac OS X) to get the creation date of your photo.I’ve been a huge fan of Eye-Fi for geotagging photos with Wi-Fi locations. It usually works well in the urban area, but sometimes tag photos in a weird location when there are bunch of mobile hotspots (conferences). It also isn’t available in the rural area.

I use gps4cam when traveling — it allows you to geotag photos by taking the QR code on your phone, and then run its Mac app to add geo data to all the RAW files. It works like magic, but I often forget to turn it on, and it also drains battery when enabled to precisely track the locations.

So I was wondering if there’s a middle ground. Because i use Android with Google Now enabled, Google knows my location history and I can grab the KML file.

Lightroom recognizes sidecar (xmp) files for geolocation for RAW files (that’s how Eye-Fi attaches location to them).

There must be a bunch of tools such as KML-to-GPX and then geotag with GPX to RAW, but i ended up writing one myself.

It scans your Google Location KML export, then compare with RAW photo’s creation time and creates .xmp sidecar files next to it. 180 lines of simple Ruby code, great for a weekend hacking.