Recently, I got a new DSLR. It’s a Canon 1200D/Rebel T5 (basically the one you choose if you don’t know anything about photography). Of course I want the geolocation in my EXIF data.
Unfortunately, there is no GPS built in. You can probably buy a GPS module and stuff, but I don’t want to buy additional stuff for something rather unimportant. As I’ve got a smartphone, I can track my position anywhere I go.
There are at least two possibly ways to track you location with Android. The first one is accurate, uses GPS and is the smart one:
Google My Tracks
There is a nice App from Google called „My Tracks“. Ensure you’ve got GPS enabled, and then just press the record button when you start shooting and press end when you’re done. Choose your track from the list, go to the menu and tap on „export“. Save as GPX and then send it to your computer (e.g. „add to dropbox“ or something). Voilá, you’ve got a GPX file. Now, go to the digiKam section.
As this tool automatically syncs your tracks to Google Drive, you can also just go there and download them all. In this case, they are KML or KMZ-files. Therefore, you have to use a perl script to convert them from KML/KMZ to GPX. How to use this script is described in the next section.
KML are uncompressed files and KMZ are compressed. Therefore KMZ files have to be uncompressed first. This can easily be done with this command:
for i in *.kmz; do unzip -p "$i" > "$(basename "$i" .kmz)".kml; done
Google Location History
Of course, there is a catch: You have to remember to start the App. But usually, you catch your camera, start walking around and shooting pictures, and as soon as you come home you notice that you’ve got forgotten to record your track.
Luckily, Google knows everything about you and especially where you’ve been. Android records the WiFi networks your smartphone sees and uploads them to Google (at least if you allowed it). Go to Google’s Location History and select the day when you’ve been shooting. If you don’t even remember this one, just select to download the last 30 days. You will get a KML file which is pretty much useless, as most tools use GPX files.
Converting KML to GPX
There are many tools which can convert KML files to GPX. But most don’t seem to work, create an empty file or cripple up your timestamps.
So go to GPS Visualizer and upload your KML file. Make sure to select GPX as output format and hit convert. Once the upload and conversation finished, you can download a GPX file. I would recommend using this nice perl script if you know what a command line is.
You can convert KML files easily by running this script on every KML file. (Make sure that you uncompressed KMZ files if there are any.)
perl kmlwpt2gpx.pl *.kml
Correlate your pictures in digiKam
This is the easy part: Select your pictures in digiKam. You may only want to tag pictures which have no geotag so far. Choose the „Table“ view and add a new column to the table. Add the „Geotagged“ column which will show you a yes/no column whether the picture has been tagged already. This makes sure you don’t overwrite accurate GPS-based locations with inaccurate WiFi-Location-based tags. Select all not-geotagged pictures. Click on Image → Geolocation → GPS Correlator and load your GPX file(s).
If you used a GPS tracker, you probably do not have to change anything. If you used Google Location History, then you have to tweak some settings. Adjust the maximum time gap to 600 secs (worked fine for me).
Then choose „manual time zone“. And then you have to calculate.
Currently, I’m in GMT+2 (Germany and Daylight Saving Time). Google is located in California which is GMT-7. So the correct offset is GMT+9. If you used the perl script above, you don’t have to adjust the timezone.
Hit „correlate“, switch to Google Maps in the upper left view (click on the globe), and check if everything is okay. Then hit Apply and wait till digiKam finished tagging your pictures.
That’s it. Happy shooting & geotagging!