ExifTool Forum

ExifTool => Newbies => Topic started by: rvajayh on July 17, 2020, 04:39:01 PM

Title: Incorrect hemisphere when copying GPS data
Post by: rvajayh on July 17, 2020, 04:39:01 PM
Definitive newbie here.

After much reading, searching, head scratching, and experimenting I was finally able to use the following code to copy data from a directory of XMP files to the corresponding ORF files:

exiftool -tagsfromfile %d%f.xmp -r -ext orf /Users/jay/Desktop/ExifTool\ test/Dir\ Test

The only data in the XMP file is GPS information that includes the correct GPSLongitudeRef value W but for some reason, the resulting ORF file thinks it's in the E hemisphere.

XMP data:
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <exif:GPSAltitude>0.0</exif:GPSAltitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
         <exif:GPSLongitude>75.913433566421105</exif:GPSLongitude>
         <exif:GPSLatitude>36.652689280480395</exif:GPSLatitude>
         <exif:GPSTimeStamp>2020-05-12T18:28:10Z</exif:GPSTimeStamp>
         <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef>
         <exif:GPSHPositioningError>0.0</exif:GPSHPositioningError>
         <photoshop:DateCreated>2020-05-12T14:28:10-04:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>


Relevant EXIF data from ORF:
---- GPS ----
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : North
GPS Latitude                    : 36 deg 39' 9.68"
GPS Longitude Ref               : East
GPS Longitude                   : 75 deg 54' 48.36"
GPS Altitude Ref                : Above Sea Level
GPS Altitude                    : 0 m
GPS Horizontal Positioning Error: 0 m
---- Composite ----
Aperture                        : 6.3
Blue Balance                    : 2.039063
Image Size                      : 4640x3472
Megapixels                      : 16.1
Red Balance                     : 1.921875
Scale Factor To 35 mm Equivalent: 2.0
Shutter Speed                   : 1/500
GPS Altitude                    : 0 m Above Sea Level
GPS Latitude                    : 36 deg 39' 9.68" N
GPS Longitude                   : 75 deg 54' 48.36" E


Why is the hemisphere being swapped?
Title: Re: Incorrect hemisphere when copying GPS data
Post by: Phil Harvey on July 17, 2020, 04:57:11 PM
The problem is that there is no GPSLatitudeRef or GPSLongitudeRef in XMP, so ExifTool generates these as Composite tags based on XMP:GPSLatitude and XMP:GPSLongitude.  Whatever wrote this XMP is doing it incorrectly.

To work around this you can copy them directly:

exiftool -tagsfromfile %d%f.xmp -all "-exif:gpslatituderef<xmp:gpslatituderef" "-exif:gpslongituderef<xmp:gpslongituderef" ...

Also, I would have to check the XMP specs to be sure, but I think that XMP:GPSLatitude and XMP:GPSLongitude may also be the wrong format in your XMP file.

- Phil
Title: Re: Incorrect hemisphere when copying GPS data
Post by: rvajayh on July 17, 2020, 05:11:39 PM
Thanks for the amazingly quick reply!

Just tried your suggestion and it works as expected with correct hemisphere and accurate location.

FYI - the XMP was generated by Apple Photos when using Export Unmodified Photo and selecting Export IPTC as XMP. I'm on the current version of Catalina - 10.15.6
Title: Re: Incorrect hemisphere when copying GPS data
Post by: Phil Harvey on July 23, 2020, 10:54:06 AM
Quote from: rvajayh on July 17, 2020, 05:11:39 PM
FYI - the XMP was generated by Apple Photos [...] on the current version of Catalina - 10.15.6

Apple is employing Microsoft's strategy of ignoring existing specifications. :(

- Phil
Title: Re: Incorrect hemisphere when copying GPS data
Post by: PeterC on April 25, 2023, 01:34:40 PM
I too am working with XMPs generated by Apple.  However, I am still having an issue after applying your suggestion.
 
An excerpt from the original XMP is
        <exif:GPSLongitude>75.48208666666666</exif:GPSLongitude>
        <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>

An excerpt of via exiftool ("...\exiftool.exe" "-gps*" -G1 "IMG_1003.xmp")
[XMP-exif]      GPS Longitude                  : 75 deg 28' 55.51" E
[Composite]    GPS Longitude Ref              : East
[Composite]    GPS Position                    : 36 deg 46' 6.93" N, 75 deg 28' 55.51" E


when i run:
"c:\Program Files (x86)\GeoSetter\tools\exiftool.exe" -tagsfromfile "IMG_1003.xmp" -all "-exif:gpslatituderef<xmp:gpslatituderef" "-exif:gpslongituderef<xmp:gpslongituderef" *.xmp

The records change to:
  <exif:GPSLongitude>75,28.9252E</exif:GPSLongitude>
  <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>

and:
[XMP-exif]      GPS Longitude                  : 75 deg 28' 55.51" E
[Composite]    GPS Longitude Ref              : East
[Composite]    GPS Position                    : 36 deg 46' 6.93" N, 75 deg 28' 55.51" E

Any suggestions as to what I am doing wrong, or how to correct this?

Thanks
-Peter.
Title: Re: Incorrect hemisphere when copying GPS data
Post by: Phil Harvey on April 25, 2023, 01:54:37 PM
Hi Peter,

You are specifically trying to write the EXIF reference tags, not the XMP-exif tags that you are reading back.  But the XMP-exif coordinate reference tags are not writable because they don't exist.  If you want to write them anyway, you'll need to create user-defined tags.

However, to write the XMP coordinates correctly, you should be able to do this:

exiftool -tagsfromfile "IMG_1003.xmp" -all:all "-xmp:gpslatitude<$xmp:gpslatitude $xmp:gpslatituderef" "-xmp:gpslongituderef<$xmp:gpslongitude $xmp:gpslongituderef" *.xmp

I've also changed "-all" to "-all:all" to preserve the original locations since the source and destination formats are the same.

- Phil
Title: Re: Incorrect hemisphere when copying GPS data
Post by: StarGeek on April 25, 2023, 06:01:45 PM
My thoughts as I read this thread

Quote from: Phil Harvey on July 17, 2020, 04:57:11 PMWhatever wrote this XMP is doing it incorrectly.

"Was it Apple?  I'll bet it was Apple"

Quote from: rvajayh on July 17, 2020, 05:11:39 PMFYI - the XMP was generated by Apple Photos when using Export Unmodified Photo and selecting Export IPTC as XMP.

"Yep, it was Apple."

We've seen this before with Apple.
Title: Re: Incorrect hemisphere when copying GPS data
Post by: wywh on April 26, 2023, 03:59:59 AM
During the last few years I have reported this Photos.app .xmp coordinates flaw to Apple a few times. Sigh.

https://www.apple.com/feedback/

So currently some clumsy workarounds must be used for images and movies.

https://exiftool.org/forum/index.php?topic=11969.msg64879#msg64879

https://exiftool.org/forum/index.php?topic=13167.msg71183#msg71183

- Matti
Title: Re: Incorrect hemisphere when copying GPS data
Post by: PeterC on April 26, 2023, 09:13:37 AM
Thanks Phil for your quick response and for this great application.

I appreciate the fact that you are trying to find me a workaround to Apple not following the standards.
 
As to the workaround, I did not see any difference in the result.    I am including the entire file in case that might show another the issue, as well as the exact command it used.   

Thanks again.


"ORIGINAL FILE"

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <exif:GPSHPositioningError>4.3552159314576819</exif:GPSHPositioningError>
         <exif:GPSImgDirection>42.983573917371828</exif:GPSImgDirection>
         <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
         <exif:GPSAltitude>91.954036770583528</exif:GPSAltitude>
         <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef>
         <exif:GPSLatitude>36.768591666666666</exif:GPSLatitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSLongitude>76.48208666666666</exif:GPSLongitude>
         <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef>
         <exif:GPSSpeed>0.0</exif:GPSSpeed>
         <exif:GPSSpeedRef>K</exif:GPSSpeedRef>
         <exif:GPSTimeStamp>2022-10-12T17:23:25Z</exif:GPSTimeStamp>
         <photoshop:DateCreated>2022-10-12T13:23:24-04:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>

"c:\Program Files (x86)\GeoSetter\tools\exiftool.exe" "-gps[LP]*" -G1 "img_1003.xmp"
Invalid TAG name: "gps[LP]*"
[XMP-exif]      GPS Latitude                    : 36 deg 46' 6.93" N
[XMP-exif]      GPS Longitude                   : 76 deg 28' 55.51" E
[Composite]     GPS Latitude Ref                : North
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 46' 6.93" N, 76 deg 28' 55.51" E

"c:\Program Files (x86)\GeoSetter\tools\exiftool.exe" -tagsfromfile "IMG_1003.xmp" -all:all "-xmp:gpslatitude<$xmp:gpslatitude $xmp:gpslatituderef" "-xmp:gpslongituderef<$xmp:gpslongitude $xmp:gpslongituderef" *.xmp
    1 image files updated

"MODIFIED FILE"

C:\Data\OneDrive\DataOnOneDrive\Photos\Library\2022\20220909-20221116\fortestingfix>"c:\Program Files (x86)\GeoSetter\tools\exiftool.exe" "-gps[LP]*" -G1 "img_1003.xmp"
Invalid TAG name: "gps[LP]*"
[XMP-exif]      GPS Latitude                    : 36 deg 46' 6.93" N
[XMP-exif]      GPS Longitude                   : 76 deg 28' 55.51" E
[Composite]     GPS Latitude Ref                : North
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 46' 6.93" N, 76 deg 28' 55.51" E


"MODIFIED FILE"

<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.30'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:GPSAltitude>74023/805</exif:GPSAltitude>
  <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
  <exif:GPSHPositioningError>37616/8637</exif:GPSHPositioningError>
  <exif:GPSImgDirection>86354/2009</exif:GPSImgDirection>
  <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef>
  <exif:GPSLatitude>36,46.1155N</exif:GPSLatitude>
  <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef>
  <exif:GPSLongitude>76,28.9252E</exif:GPSLongitude>
  <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
  <exif:GPSSpeed>0/1</exif:GPSSpeed>
  <exif:GPSSpeedRef>K</exif:GPSSpeedRef>
  <exif:GPSTimeStamp>2022-10-12T17:23:25Z</exif:GPSTimeStamp>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
  <photoshop:DateCreated>2022-10-12T13:23:24-04:00</photoshop:DateCreated>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
Title: Re: Incorrect hemisphere when copying GPS data
Post by: Phil Harvey on April 26, 2023, 10:43:47 AM
I think your problem is FAQ 3 (https://exiftool.org/faq.html#Q3).  You aren't seeing the duplicate tags without the -a option.  When I save your XMP to a file named "a.xmp", I get this, which I thought is what we wanted:

> exiftool a.xmp "-gpslongitude*" -a -G
[XMP]           GPS Longitude Ref               : W
[XMP]           GPS Longitude                   : 76 deg 28' 55.51" E
[Composite]     GPS Longitude Ref               : East
> exiftool a.jpg -tagsfromfile a.xmp '-xmp:gpslongitude<$xmp:gpslongitude $xmp:gpslongituderef'
    1 image files updated
> exiftool a.jpg "-gpslongitude*" -a -G
[XMP]           GPS Longitude                   : 76 deg 28' 55.51" W
[Composite]     GPS Longitude Ref               : West

Note that you'll have to use double quotes in the second command (as per my signature) if you are running in a Windows CMD shell.

- Phil

Edit:  On second thought, the difference may be that you are using an old version of ExifTool.  Please upgrade to the current version.