Skip to content

Instantly share code, notes, and snippets.

@natecostello
Last active October 5, 2022 03:20
Show Gist options
  • Save natecostello/2d6002b6f97cb03f89df3ed5b6e8a284 to your computer and use it in GitHub Desktop.
Save natecostello/2d6002b6f97cb03f89df3ed5b6e8a284 to your computer and use it in GitHub Desktop.
Notes on Geotagging with exiftool

Notes On Geotagging

Our camera doesn't have a GPS. If we have a GPX track, we can tag all photos in a directory as follows:

  1. Ensure the GPX zulu + offset time matches the "Date/Time Original" field of the photos to be tagged.
exiftool -datetimeoriginal photo_to_be_tagged.jpg
  1. Copy the GPX file into the directory with the photos to be tagged.

  2. Run the following command from a terminal working in that same directory:

exiftool -geotag [GPX-FILENAME].gpx * -api GeoMaxExtSecs=300 -api GeoMaxIntSecs=300

Notes:

-geotag is the exiftool option to perform geotagging.

[GPX-FILENAME].gpx is the path and file name of the GPX track to be used.

* is the path and file name of the photos to be tagged. This could also be a specific file name.

-api GeoMaxExtSecs=300 limits extrapolation to 5 minutes (300 seconds) beyond a GPX point. This prevents photos that are > 5 minutes outside of the time of the GPX track from being tagged.

-api GeoMaxIntSecs=300 limits interpolation to 5 minutes (300 seconds) between GPX points. This simply allows linear interpolation of position instead of tagging it to the closest point.

  1. Once happy, delete the preserved "original files" saved by exiftool for files that were modified.
rm *_original

If you don't have a GPX track

If you just want to use coordinates from google maps, you can use the following. Note, if you just reuse the lat or long coordinate for the reference arguments, exiftool will figure it out:

exiftool *.JPG -gpslatitude=[gps lat from google maps]  -gpslongitude=[gps long from google maps] -gpslatituderef=[gps lat from google maps] -gpslongituderef=[gps long from google maps]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment