Help With Extracting GPS Tags

Started by SashaSolitaire, May 20, 2025, 09:05:10 PM

Previous topic - Next topic

SashaSolitaire

System: Windows 10 64-bit
Exiftool: Ver 13.29

I regularly export all EXIF data from all my photos using the following command:

<<PATH TO EXIFTOOL>>\ExifTool.exe -j -r -ext CR2 -ext jpg -ext jpeg -ext CR3 <<PATH TO PHOTOS FOLDER>> > <<PATH TO JSON>>\Exif_YYYYMMDD.json

Once the data is extracted, it's all loaded into a SQL DB for analysis. I recently got myself a Canon GP-E2 GPS receiver which enables logging of the GPS coordinates. When I try the export using the command above, the only GSP related tag I get is the GPSversionID.

I am currently exporting the GPS tags using the following command:

<<PATH TO EXIFTOOL>>\ExifTool.exe -if "$gpslongitude ge 0" -j -a -G -sourcefile -gps* -c "%.6f" -r <<PATH TO PHOTOS FOLDER>> > <<PATH TO JSON>>\Exif_GPS_Tags_YYYYMMDD.json

Why are the rest of the GPStags like the Altitude, AltitudeRef etc., not coming through with my first command? Is there anything I can do to get all the GPS tags to flow through in one extract command?


StarGeek

Can you share a sample file? You will probably have to do so through something like dropbox/google drive.

If you use Google drive, make sure the link isn't restricted. See this post.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

SashaSolitaire

#2
@StarGeek, sorry about the delay. Here's the link to one .CR3 image which has the GPS tags.

https://drive.google.com/file/d/1FcX_qQmwSG85F06TXYiZbS2eDmakPF9u/view?usp=sharing

Here are the GPS coordinates as they appear in my editor:

2025-05-21 12_09_58-DxO PhotoLab 8.6.jpg

StarGeek

The GPS coordinates are there in the JSON output. How are you adding them to your database? Does this way account for the default format of the GPS coordinates, which looks like this in the JSON
  "GPSAltitude": "96.7 m Above Sea Level",
  "GPSDateTime": "2025:05:01 15:51:12.006Z",
  "GPSLatitude": "40 deg 59' 13.98\" N",
  "GPSLongitude": "73 deg 52' 38.90\" W",

Maybe if you add the -c (-coordFormat) option in your first command as you did in the second command to change the output to be numeric
exiftool -j -r -c "%.6f" -ext CR2 -ext jpg -ext jpeg -ext CR3 /path/to/files/ >/path/to/Exif_YYYYMMDD.json
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

SashaSolitaire

I have not yet loaded anything into the database. Attaching the JSON for the image I got using the command <<PATH TO EXIFTOOL>>\ExifTool.exe -j -r -ext CR2 -ext jpg -ext jpeg -ext CR3 <<PATH TO PHOTOS FOLDER>> > <<PATH TO JSON>>\Exif_YYYYMMDD.json

As you can see (lines 261 on), these are the only GPS fields:

  "GPSVersionID": "2.3.0.0",
  "GPSAltitudeRef": "Above Sea Level",
  "GPSSatellites": "",
  "GPSStatus": "Unknown ()",
  "GPSMeasureMode": "Unknown ()",

However, running the command D:\ExifTool\ExifTool.exe -j -c "%.6f" -ext CR2 -ext jpg -ext jpeg -ext CR3 I:\Photos_By_Year\2025\May\_MG_2900.CR3 does provide the GPS coordinates (see the attached file _MG_2900.CR3.Revised.json):

  "GPSVersionID": "2.3.0.0",
  "GPSLatitudeRef": "North",
  "GPSLongitudeRef": "West",
  "GPSAltitudeRef": "Above Sea Level",
  "GPSTimeStamp": "15:51:12.006",
  "GPSSatellites": 12,
  "GPSStatus": "Measurement Active",
  "GPSMeasureMode": "3-Dimensional Measurement",
  "GPSDOP": 9.2,
  "GPSMapDatum": "WGS-84",
  "GPSDateStamp": "2025:05:01",
  "GPSAltitude": "96.7 m Above Sea Level",
  "GPSDateTime": "2025:05:01 15:51:12.006Z",
  "GPSLatitude": "40.987217 N",
  "GPSLongitude": "73.877472 W",
  "GPSPosition": "40.987217 N, 73.877472 W",

Thank you for your help. This resolves my issue. Did not realize that I had to specify the format for the GPS data for it to be extracted. I'll rerun the modified code over all the photos in my folders and will update this thread.

StarGeek

Scroll down to the bottom of the JSON. You'll find the GPS coordinates around line 360.
  "SubSecDateTimeOriginal": "2025:05:01 11:48:59.59-04:00",
  "SubSecModifyDate": "2025:05:01 11:48:59.59-04:00",
  "GPSAltitude": "96.7 m Above Sea Level",
  "GPSDateTime": "2025:05:01 15:51:12.006Z",
  "GPSLatitude": "40 deg 59' 13.98\" N",
  "GPSLongitude": "73 deg 52' 38.90\" W",
  "AvgBitrate": "451 Mbps",
  "Rotation": 0,
  "Lens35efl": "140.0 - 700.0 mm (35 mm equivalent: 139.8 - 698.9 mm)",
  "CircleOfConfusion": "0.030 mm",
  "DOF": "2.41 m (43.46 - 45.87 m)",
  "FOV": "3.0 deg",
  "FocalLength35efl": "700.0 mm (35 mm equivalent: 698.9 mm)",
  "GPSPosition": "40 deg 59' 13.98\" N, 73 deg 52' 38.90\" W",
  "HyperfocalDistance": "1628.36 m",
  "LightValue": 14.3
}]

The reason they aren't appearing above with the other GPS tags is because these are the Composite GPS tags (see the Composite tags page). The Composite tags are calculated last and will appear at the end.

The EXIF GPS tags are separated into two tags. The actual coordinates and the reference direction. If you add the -G (-groupNames) option, you'll see something like this around line 350
"EXIF:LensModel": "RF100-500mm F4.5-7.1 L IS USM + EXTENDER RF1.4x",
  "EXIF:LensSerialNumber": 9103001864,
  "EXIF:GPSVersionID": "2.3.0.0",
  "EXIF:GPSLatitudeRef": "North",
  "EXIF:GPSLatitude": "40 deg 59' 13.98\"",
  "EXIF:GPSLongitudeRef": "West",
  "EXIF:GPSLongitude": "73 deg 52' 38.90\"",
  "EXIF:GPSAltitudeRef": "Above Sea Level",
  "EXIF:GPSAltitude": "96.7 m",
  "EXIF:GPSTimeStamp": "15:51:12.006",
  "EXIF:GPSSatellites": 12,
  "EXIF:GPSStatus": "Measurement Active",
  "EXIF:GPSMeasureMode": "3-Dimensional Measurement",
  "EXIF:GPSDOP": 9.2,
  "EXIF:GPSMapDatum": "WGS-84",
  "EXIF:GPSDateStamp": "2025:05:01",
  "XMP:Rating": 0,

And down at the bottom
  "Composite:SubSecModifyDate": "2025:05:01 11:48:59.59-04:00",
  "Composite:GPSAltitude": "96.7 m Above Sea Level",
  "Composite:GPSDateTime": "2025:05:01 15:51:12.006Z",
  "Composite:GPSLatitude": "40 deg 59' 13.98\" N",
  "Composite:GPSLongitude": "73 deg 52' 38.90\" W",
  "Composite:AvgBitrate": "451 Mbps",
  "Composite:Rotation": 0,

The reason you don't see both without the -G option can be found in the docs on the -j (-json) option
QuoteThe -a (-duplicates) option is implied when -json is used, but entries with identical JSON names are suppressed in the output.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Ok, wait a second. Something is off. The JSON output I get from your posted file is very different from the JSON you posted.

Here are the differences on DiffChecker. Even though the names are the same, the dates, the exposure time, ISO, etc are different.

An additional thing to take note of is the JSON you uploaded was created with exiftool 12.96.

To be complete, here is the output (Pastebin) on your file using exiftool 13.29.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

SashaSolitaire

You are correct on both fronts. I thought that my download of the Ver 13.29 went in to the correct folder, but my D:\ExifTool folder which I kicked off the extract from was still on Ver 12.96. I copied over the correct version (13.29) and could see the GPS attributes. Using the -G option does indeed provide all the composite fields too. Thanks again for nailing this down. Overconfidence on my part to assume that I had indeed updated to the latest version of ExifTool, when I clearly did not.