Using -n to get decimal GPS coordinates won't allow date formatting

Started by omarserenity, January 27, 2024, 01:22:15 AM

Previous topic - Next topic

omarserenity

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?

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

There's also the -c (-coordFormat) option, 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 which gives the approx distance for each decimal of precision.
"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

Phil Harvey

@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.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Yep, me too.  One reason I went searching for a listing like that.
"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

omarserenity

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.