negative GPS values are written as positive

Started by elewis2, December 22, 2023, 12:53:03 PM

Previous topic - Next topic

elewis2

Example
Issue the command:
-GPSLatitude=24.0 -GPSLatitudeRef=S -GPSLongitude=31.76 <some file.mp4>
updates the file, however the file is assigned GPS location 24.0 north and 31.76 east. The north latitude is incorrect; it should be south. I have tried variants of the command as -gpslatitude= and using "South" instead of S. Command still does not work. I also tried an arbitrary location for places in the western hemisphere. Assigned latitude is always east, even if specifying W or "West". (In case, east is fine and expected as I did not specify E!).
Exiftool version: 12.71
System: Mac M1 Professional
OS Version: Sonoma 14.2.1.

StarGeek

There are no reference tags in a video file.  When writing GPSLatitude, GPSLongitude, and GPSAltitude, you include the direction. This is because you are writing to XMP tags instead of the EXIF GPS tags.  EXIF tags in a video are non-standard, so you can't create them in a video. So you would use:
exiftool -GPSLatitude=-24.0 -GPSLongitude=31.76 file.mp4

Example
C:\>exiftool -all= -P -overwrite_original -GPSLatitude=-24.0 -GPSLongitude=31.76  Y:\!temp\Test1.mp4
    1 image files updated

C:\>exiftool -G1 -a -s -gps* Y:\!temp\Test1.mp4
[XMP-exif]      GPSLatitude                     : 24 deg 0' 0.00" S
[XMP-exif]      GPSLongitude                    : 31 deg 45' 36.00" E
[Composite]     GPSLatitudeRef                  : South
[Composite]     GPSLongitudeRef                 : East
[Composite]     GPSPosition                     : 24 deg 0' 0.00" S, 31 deg 45' 36.00" E

Additionally, video files have their own GPS tag which includes all three coordinates.  For that you would write
exiftool -GPSCoordinates="-24, 31.76, 10" file.mp4

An easier command which will write to the EXIF GPS tags as well as the XMP GPS tags as  needed would be to write the Composite:GPSPosition tag.  In this example you can see that it wrote the correct data to both an MP4 and a jpeg
C:\>exiftool -all= -P -overwrite_original -GPSPosition="-24.0, 31.76"  Y:\!temp\Test1.mp4 y:\!temp\Test4.jpg
    2 image files updated

C:\>exiftool -G1 -a -s -gps* Y:\!temp\Test1.mp4 y:\!temp\Test4.jpg
======== Y:/!temp/Test1.mp4
[XMP-exif]      GPSLatitude                     : 24 deg 0' 0.00" S
[XMP-exif]      GPSLongitude                    : 31 deg 45' 36.00" E
[Composite]     GPSLatitudeRef                  : South
[Composite]     GPSLongitudeRef                 : East
[Composite]     GPSPosition                     : 24 deg 0' 0.00" S, 31 deg 45' 36.00" E
======== y:/!temp/Test4.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : South
[GPS]           GPSLatitude                     : 24 deg 0' 0.00"
[GPS]           GPSLongitudeRef                 : East
[GPS]           GPSLongitude                    : 31 deg 45' 36.00"
[Composite]     GPSLatitude                     : 24 deg 0' 0.00" S
[Composite]     GPSLongitude                    : 31 deg 45' 36.00" E
[Composite]     GPSPosition                     : 24 deg 0' 0.00" S, 31 deg 45' 36.00" E
    2 image files read

The video GPSCoordinates still has to be written separately.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

If this is years old Photos.app .xmp issue (or similar) you might fix that nonstandard .xmp with:

exiftool -P -overwrite_original -XMP-exif:All= -tagsFromFile @ -XMP-exif:All '-XMP-exif:GPSLongitude<${XMP-exif:GPSLongitude#}${XMP-exif:GPSLongitudeRef#}' '-XMP-exif:GPSLatitude<${XMP-exif:GPSLatitude#}${XMP-exif:GPSLatitudeRef#}' *.xmp
Then use this to copy .xmp to images:

exiftool -m -overwrite_original_in_place -ext jpg -ext heic '-IPTC:CodedCharacterSet=UTF8' -tagsFromFile %d%f.xmp '-AllDates<XMP-photoshop:DateCreated' '-ExifIFD:OffsetTime*<XMP-photoshop:DateCreated' '-XMP-photoshop:DateCreated<XMP-photoshop:DateCreated' '-EXIF:All<XMP-exif:All' '-GPS:GPSLatitudeRef<Composite:GPSLatitudeRef' '-GPS:GPSLongitudeRef<Composite:GPSLongitudeRef' '-XMP:All<XMP:All' '-IPTC:ObjectName<XMP-dc:Title' '-IPTC:Caption-Abstract<XMP-dc:Description' '-EXIF:ImageDescription<XMP-dc:Description' '-IPTC:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
...and this to copy .xmp to movies:

exiftool -m -overwrite_original_in_place -api QuickTimeUTC=1 -ext mp4 -ext m4v -ext mov -tagsFromFile %d%f.xmp -api QuickTimeUTC=1 '-AllDates<XMP-photoshop:DateCreated' '-Track*Date<XMP-photoshop:DateCreated' '-Media*Date<XMP-photoshop:DateCreated' '-Keys:CreationDate<XMP-photoshop:DateCreated' '-Keys:GPSCoordinates<$XMP:GPSLatitude#, $XMP:GPSLongitude#' '-Keys:Title<XMP-dc:Title' '-Keys:Description<XMP-dc:Description' '-Keys:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
https://exiftool.org/forum/index.php?topic=12634.msg68327#msg68327

- Matti