Digital Geography

5. January 2015

Geotagging Basics with ExifTool

 

Geotagged Images with 3D Point Cloud

Why Geotagging?

In a recent post, I discussed the new drone that I got for the holidays and a bit about how I was using it for developing map products.  I do this using structure from motion algorithms and when working with a lot of images it is a great help if there is a good initial estimate of the image location.  This is where geotagging comes in.

If you have a smartphone, then you are familiar with geotagging.  Most iPhone and Android devices tag their images when they are collected.  That is great if you are uploading to Facebook or Pinterest, but may not be the best for mapping applications.  I need images that have an accurate time stamp and complete position information, including latitude, longitude, and altitude.  Many smartphones include the first two, but often altitude is ignored.  In my case one of the cameras I use is a GoPro Hero3, which does not provide position information natively.  This is where Phil Harvey’s excellent program ExifTool comes in.

Basic Geotagging

There are a lot of tools for dealing with image EXIF and GPS data, but ExifTool has two big things in its favor.  First, you will not find a tool that is more full-featured or better able to work with EXIF data.  Second, it is free and open-source.  ExifTool is available for virtually any platform as both a Perl library and a standalone command-line utility.  In many cases I prefer to use the command-line utility and that is what will be used for geotagging.

Of course, beyond the tool you will need an image or a set of images (in a directory) and a file containing your GPS data.  The latter is most often in the form of a .gpx file.  You might get this from your GPS unit via interface software (like GPSBabel) or you might make it yourself using other format logs.  In my case, I have a text file of GPS information from my drone, written at 5Hz, and I wrote a python script to convert it to GPX.  GPX is a simple xml derivative, so is easy to read and create.

Basic geotagging an entire directory of images with ExifTool is as simple as:

exiftool -geotag your-GPX-file.gpx /your/directory/images

To geotag only one image

exiftool -geotag your-GPX-file.gpx /dir/images/your-image.jpg

If you have GPS metadata, exiftool will overwrite it.  If there were no GPS tags to begin with then exiftool will create them.  There is also a -geosync option for modifying the time in your image files to correct for clock offsets in your camera.  The most common issue I run into is that the GeoTime tag is not set and without this the images cannot be geotagged.  There is an easy fix for this as well.  Just use the -geotime option.

exiftool -geotag file.gpx "-geotime<filemodifydate" -P imagedir

This will set the GeoTime tag to the file modify date, which is typically when the file was created.  The -P preserves the original times and the -geosync option can be used after you have set the GeoTime.

I have only scratched the surface of what ExifTool can do, but hopefully enough to pique your interest.  ExifTool is a great free program for various functions involving EXIF image metadata and I encourage folks to check it out at Phil Harvey’s page.   For those interested in a much more detailed look at geotagging with ExifTool please look here.

As always, I hope this is useful to you and thank you for reading.

  • EricSGoldstein

    Hey – can you tell me what type of drone / quad you’re using?

    I have a Phantom 2 with a h3-3d, IOSD, etc., and also a FlyTrex.

    I don’t have the Ground Station, but curious about how to do mapping and geotagging with the Phantom.

    Any thoughts would be great.

    • EricSGoldstein

      Just read your other post:

      http://www.digital-geography.com/droneforholiday/#.VM-8GlXN_aF

      And saw you’ve got a Vision+. Good comparison with the Iris as well..

      I’m assuming that you’re looking at things like the Ground Station for Way Points, but curious how I can get GPS data if I have a Phantom 2, not a Vision+. I have a FlyTrex and that captures the data, but I think I need to find a way to sync images very accurately with the time data of the Flytrex.

      • Scott Arko

        Hello again,

        I don’t believe there is a way to extract logs from the DJI products. At least not one that I’ve ever found.

        Scott

    • Scott Arko

      Hi Eric,

      Thanks for the comment and sorry for the delay in answering. I have a 3DR IRIS+ that I used for this article. The reason I prefer it over the Phantom is that you can get direct access to the system logs from the quad, including the GPS log. This allows me to extract lat/lon/alt at 5Hz for the entire flight. While this is not accurate enough to do precision work, it is often good enough. I typically get RMSE of less than 5m using only the quad GPS. Add in a bit of survey-grade ground control and you move to cm accuracy.

      Scott

  • Ron Bates

    I have heard a lot of great things about ExifTool. I have been looking into geotagging and it seems like most people focus on the software/programs. I have been looking into those, but I have also been looking into hardware as well, cameras/gps data loggers and what not. I haven’t looked into a drone yet, but that sounds like a whole lot of fun. But for basic geotagging, this article lists some good stuff for starters like me.
    Check it out: http://www.paintshoppro.com/en/landing/geotag-photos/
    Thanks again.