Can anyone recommend a Python library(s) that can geotag a photograph with the lat/long coordinates by correlating the timestamp of the photograph to the timestamp of a waypoint within a GPX file?

I am aware of desktop applications like GeoSetter which will do this for you, but I would like to write an automation procedure that I could run on a nightly basis that emulates this process:

  1. User takes a GPS and a camera into the field.
  2. User drops a folder onto a server with a GPX file and the photos taken that day.
  3. A Python process geotags the metadata each photo in the folder with the lat/long coordinates by comparing the photo timestamp to the nearest equivalent timestamp (+/- 30 seconds?) of a waypoint in the GPX file.
  4. Convert the coordinates found in the photo's metadata to a point in a GIS system.

I have procedures in place for steps 1, 2, & 4 but either need to find a library that already accomplishes step 3 or write my own. Any suggestions?

  • You could use Exiv2 to edit the images' metadata and just write your on function where you grab the two timestamps and compare them. – ustroetz Jan 14 '14 at 23:10
  • Yes, I am familiar with writing to the EXIF metadata. The existence of a pre-built comparison library is what I am most interested. No need to re-invent the wheel if it already exists. – RyanKDalton Jan 14 '14 at 23:20
  • You could have a look at the source code of the command-line utility HappyCamel or at GPicSync, which are both written in Python. There are several ready-to-use command-line tools specified on this list of geocoding software, if non-Python is an option. A widely used command line utility is the gpsPhoto Perl Script which makes use of ExifTool library. – lavarider Jan 15 '14 at 9:45

On the ArcGIS stack, there is the Match Photos To Rows By Time which you can use after you've imported your GPX files as point feature classes. From there if you need the GPS fix back in the EXIF tags, you could use pexif on the original files.

  • Thanks Jason. Looks like this is available at 10.1 also. I had used the GeoTagged Photos To Points sample and included ExifUtils.py to generate points from the photos (step 4 above) but pexif looks pretty simple. I will look into it. – RyanKDalton Jan 14 '14 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.