ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: omarserenity on January 27, 2024, 01:22:15 AM

Title: Using -n to get decimal GPS coordinates won't allow date formatting
Post by: omarserenity on January 27, 2024, 01:22:15 AM
I've looked everywhere for an answer for this. I'd like to format all my dates a specific way and have decimal degrees in my GPS coordinates without a + sign on the positive values, but when I try to use the -n option to get rid of the + sign, my -d FMT doesn't seem to work.
Here's an example (the -MD5 and -SHA256 user-defined composite tags are from config file tricks I learned from this forum):
exiftool -progress -n -c '%+.6f' -GPSLatitude -GPSLongitude -MD5 -SHA256 -alldates -d '%Y-%m-%d %H:%M:%S' -Directory -BaseName -FileName -ImageHeight -ImageWidth -Orientation --ext xmp --ext txt -j "/mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville/_MG_6750.CR2"

Output:
======== /mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville/_MG_6750.CR2 [1/1]
[{
  "SourceFile": "/mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville/_MG_6750.CR2",
  "GPSLatitude": 34.609592,
  "GPSLongitude": -86.273979,
  "MD5": "eec29ee024991a9df9070d8357cbc56c",
  "SHA256": "00096eea69229f3c5f9e76a0b4050161a70fdc8a529f3771ae2267e714da5769",
  "DateTimeOriginal": "2020:12:22 12:27:26",
  "CreateDate": "2020:12:22 12:27:26",
  "ModifyDate": "2020:12:22 12:27:26",
  "Directory": "/mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville",
  "BaseName": "_MG_6750",
  "FileName": "_MG_6750.CR2",
  "ImageHeight": 3456,
  "ImageWidth": 5184,
  "Orientation": 1
}]

If I remove the -n, I get properly-formatted dates, but then get the + sign on my positive GPS Latitude (and it quotes it, as a string):
exiftool -progress  -c '%+.6f' -GPSLatitude -GPSLongitude -MD5 -SHA256 -alldates -d '%Y-%m-%d %H:%M:%S' -Directory -BaseName -FileName -ImageHeight -ImageWidth -Orientation --ext xmp --ext txt -j "/mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville/_MG_6750.CR2"

======== /mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville/_MG_6750.CR2 [1/1]
[{
  "SourceFile": "/mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville/_MG_6750.CR2",
  "GPSLatitude": "+34.609592",
  "GPSLongitude": -86.273979,
  "MD5": "eec29ee024991a9df9070d8357cbc56c",
  "SHA256": "00096eea69229f3c5f9e76a0b4050161a70fdc8a529f3771ae2267e714da5769",
  "DateTimeOriginal": "2020-12-22 12:27:26",
  "CreateDate": "2020-12-22 12:27:26",
  "ModifyDate": "2020-12-22 12:27:26",
  "Directory": "/mnt/SynologyPhoto/Canon RAW Images/2020-12-22 North of Huntsville",
  "BaseName": "_MG_6750",
  "FileName": "_MG_6750.CR2",
  "ImageHeight": 3456,
  "ImageWidth": 5184,
  "Orientation": "Horizontal (normal)"
}]

What obvious thing am I missing?
Title: Re: Using -n to get decimal GPS coordinates won't allow date formatting
Post by: Phil Harvey on January 27, 2024, 09:07:58 AM
The -n selects the numerical (eg. unformatted) value for all tags.  Instead of this, add "#" to the specific tag names where you want the numerical value (eg. -gpslatitude#).

- Phil
Title: Re: Using -n to get decimal GPS coordinates won't allow date formatting
Post by: StarGeek on January 27, 2024, 10:22:35 AM
There's also the -c (-coordFormat) option (https://exiftool.org/exiftool_pod.html#c-FMT--coordFormat), though you would have to set the precision.

C:\>exiftool -s -G -Composite:GPS* -n y:\!temp\Test4.jpg
[Composite]     GPSLatitude                     : 40.6892
[Composite]     GPSLongitude                    : -74.0445451322417
[Composite]     GPSPosition                     : 40.6892 -74.0445451322417

C:\>exiftool -s -G -Composite:GPS* -c "%+.10f" y:\!temp\Test4.jpg
[Composite]     GPSLatitude                     : +40.6892000000
[Composite]     GPSLongitude                    : -74.0445451322
[Composite]     GPSPosition                     : +40.6892000000, -74.0445451322

Related, this GIS StackExchange answer (https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude/8674#8674) which gives the approx distance for each decimal of precision.
Title: Re: Using -n to get decimal GPS coordinates won't allow date formatting
Post by: Phil Harvey on January 27, 2024, 10:44:43 AM
@StarGeek: To quote your stack exchange link:

"Ten or more decimal places indicates a computer or calculator was used and that no attention was paid to the fact that the extra decimals are useless."

... made me think of this thread (https://exiftool.org/forum/index.php?topic=15624.0).

- Phil
Title: Re: Using -n to get decimal GPS coordinates won't allow date formatting
Post by: StarGeek on January 27, 2024, 02:04:34 PM
Yep, me too.  One reason I went searching for a listing like that.
Title: Re: Using -n to get decimal GPS coordinates won't allow date formatting
Post by: omarserenity on February 03, 2024, 09:29:29 PM
Thanks, guys! That works perfectly.
@StarGeek: I was already using the -c switch for formatting, but without the -n, it was giving me the + sign on positive values, which apparently was because it was using the formatted value from the tag. Removing the -n and adding the # onto the end of -GPSLatitude -GPSLongitude gave me what I needed, formatting dates correctly and leaving the + off of the positive latitude values.