Author Topic: Need help with extracting GPS data from photo reconnaissance image files  (Read 156 times)

naturephotoguy

  • Newbie
  • *
  • Posts: 2
For forum members and our fearless leader: I am a pilot with the Civil Air Patrol here in the U.S. We do search and rescue, but equally often, we are tasked with photo reconnaissance. For example, we may be asked to take aerial photos to document damage after a natural disaster. Our GPS units geotag photos with critical information: lat/long, UTC time, altitude, and the direction the camera was pointing when the exposure was made. We are required to extract all this information for the photos made during a flight, and to enter it into a fillable MS Word document. Based on other posts in this forum, I tried this command line: exiftool -filename -gpslatitude -gpslongitude "/Users/[my username]/Desktop/CAP_SAREX_images" > out.csv  .

This worked well, but did not extract time, altitude, or the direction the camera was pointed. I know this information is in the file, because the Mac Preview app extracts it. As you might guess, what I would like to do is - with the help of people far more knowledgeable than myself - create an app that will extract this information and export it to an Excel spreadsheet. From there, it would be easier to import it into the fillable Word document. The ultimate goal, of course, would be to create some sort of Word macro to eliminate all copying and pasting, but for now I'd be happy if you could help with a command line that would extract all the essential GPS data from the file. If successful, this could be a template for our operations nationwide.

I'm attaching a sample geotagged file and a screenshot from Preview showing the data I need. I'd be grateful for any assistance.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
To get the timestamp, add -GPSDateTime, assuming you want the UTC timestamp.  To get the altitude, add -GPSAltitude.  To get the direction, add -GPSImgDirection (I think).

Your final command would be something like:
exiftool -filename -gpslatitude -gpslongitude -GPSAltitude -GPSDateTime -GPSImgDirection "/Users/[my username]/Desktop/CAP_SAREX_images" > out.csv  .

To look at all the data in an image, you can run exiftool -G1 -a -s FILE  That will give you the group name and the tag name of each piece of data. 

Also, just in case you want the coordinates in a different format, take a look at the -c (coordFormat) option
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
Some further thoughts.  Since your target use is to paste the data into a Word doc, it might be possible to skip the intermediate step of creating the csv file and copy the exiftool output directly to the clipboard in the desired format.

For example, try this command:
exiftool -p "FileName: $FileName$/GPSLatitude: $GPSLatitude$/GPSLongitude: $GPSLongitude$/GPSAltitude: $GPSAltitude$/GPSDateTime: $GPSDateTime$/GPSImgDirection: $GPSImgDirection"  FILE | pbcopy

This command uses the -p (printFormat) option to change the output format of the data.  This is then piped into the Mac's pbcopy command, which places it onto the clipboard.  You could then switch to word and directly paste it.

Here's what the output of the above command looks like on your sample file:
Code: [Select]
FileName: CAP_sample.jpg
GPSLatitude: 35 deg 34' 41.64" N
GPSLongitude: 106 deg 18' 14.27" W
GPSAltitude: 2036 m Above Sea Level
GPSDateTime: 2019:03:23 18:13:58Z
GPSImgDirection: 40.2
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

naturephotoguy

  • Newbie
  • *
  • Posts: 2
This is a very helpful reply. Thanks! Can the lat/long be rendered in degrees/minutes.decimal minutes?

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
Also, just in case you want the coordinates in a different format, take a look at the -c (coordFormat) option
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

jcharmon

  • Jr. Member
  • **
  • Posts: 27
From a quick look at your sample photo, it looks like this particular photo was taken with a Nikon D7200 with embedded GPS data. As you've seen, ExifTool is quite capable of extracting all this metadata.

I wonder if your CAP unit would be well served with a dedicated digital asset management program, which would be able to organize and manipulate all of the metadata you track (and more, including location shown). One example of this is IMatch https://www.photools.com/ (Windows), which uses ExifTool for handling metadata.