Timelapse: 1. Geocoding

Monday, 21 December, 2015

Following on from last week’s blog, the first stage in putting together the timelapse video with inset map is to geocode the photos. This post entirely uses the quite remarkable ExifTool for manipulating photo EXIF data that’s embedded within images. It’s fast, has extensive capabilities and is very well supported. it’s command-line only although there are numerous front-end GUIs for it, including both Geosetter (which I’ve mentioned before) and ExifToolGUI. That said, for processing the large number of images for a timelapse it’s much easier to use the command line.

Pre-Requisites
GPS tracklog
photos

1. Timeshift

Step 1 is to timeshift your images. All location information is stored in the GPS tracklog, however because GPS uses the extremely accurate clocks on board the individual satellites to calculate position, the log also stores time. They are usually supplied as GPX (GPS Exchange Format) files which are standardised XML files for GPS data transfer. Most GPSs natively support this now, but if you have an older device you may need to convert to GPX. GPSBabel should be able to handle this for you.

This stage is critical in order to synchronise the time tagged in the EXIF data of the photos to the GPS. The GPX files often record speed as well, so I scan through the GPX file (its text) looking at the start of the data when speed goes above 0 mph. That’s the start of the ride and, within a few seconds, your first photo. Write that down! Now load the first photo and look at the EXIF data (I use Xnview) “Date Modified” tag (in fact several dates can be recorded in the EXIF data, but we’ll be setting them all the same) and write it down. Now check whether those two dates are the same - if they’re not then you need to timeshift your photos. My GoPro had reset itself to the default firmware date of 1 January 2009.

You now need to calculate the time between two dates. I’ve used this website although Excel can do it as well. My images were 866 days, 18 hours, 26 minutes and 25 seconds out!!! The ExifTool command to timeshift this is

exiftool -AllDates+=”0:0:866 18:26:25” .

(the period tells it to process all files in the current directory). If you are doing a multi-day event then all your photos may or may not be consistently out. It turned out the camera reset its clock again halfway through so I then needed to use a different timeshift value. And, then, on two further days there were sections were the clock was wrong. Not sure why but it needed fixing.

2. Geocode

With the photos now correctly timestamped you can geocode the images. ExifTool is pretty clever here in that it reads the time, scans the entire GPX file finding the nearest times before and after the photo and then linearly interpolates between the two GPS locations based upon the time offset. It then writes this information back in to the EXIF data. It also has the option (geosync) to cater for timezones (as GPS uses UTC). The command here is:

exiftool -geosync=+01:00:00 -geotag ..\18_raw.gpx .

3. CSV Output

With all the photos geocoded the final stage, ready for creating the inset maps, is to produce a file listing with all photo coordinates. ExifTool can again do this:

exiftool -csv -n -filename -imagesize -gpslatitude -gpslongitude ./ > coords.csv

Later this week I’ll cover creating the inset maps and then combining all the elements together to produce the final video.