Author Topic: Copy GPS coord tags - Wrong Hemisphere!  (Read 2025 times)

mpollack

  • Newbie
  • *
  • Posts: 9
Copy GPS coord tags - Wrong Hemisphere!
« on: March 07, 2016, 07:16:23 PM »
Hi All,

I am trying to copy the GPS coordinates from a MOV file to a THM file.

First I check the relevant GPS tags of the source file:

$ exiftool -gps:all -a -gpslatitude -gpslongitude -n IMG*.MOV

returns

GPS Latitude                    : 37.316
GPS Longitude                   : -122.0599


I start by clearing out all tags on the THM file with the following:
$ exiftool -overwrite_original -all= IMG_1748.THM

And inspecting the tags of the THM file with
$ exiftool -gps:all -a -gpslatitude -gpslongitude -n IMG*.THM
returns nothing. That is, those tags don't exist.

Then I copy the tags from the source to the destination with the following:
$ exiftool -overwrite_original -tagsfromfile IMG_1748.MOV  IMG_1748.THM

And then recheck the GPS metadata:
$ exiftool -gps:all -a -gpslatitude -gpslongitude -n IMG_1748.*
======== IMG_1748.MOV
GPS Latitude                    : 37.316
GPS Longitude                   : -122.0599
======== IMG_1748.THM
GPS Version ID                  : 2 3 0 0
GPS Latitude                    : 37.316
GPS Longitude                   : 122.0599
GPS Altitude Ref                : 0
GPS Altitude                    : 93.751
GPS Latitude                    : 37.316
GPS Longitude                   : 122.0599


The result is confusing to me in two ways. First, there are duplicate tags for GPS Latitude and GPS Longitude. Second, and more importantly, the minus sign on the source file's Longitude has disappeared.

Is this a bug, or am I doing something wrong? Any advice on how to clean this up would be greatly appreciated.

Thanks in advance,

Michael

PS The same anomalous behavior is observed when I used a JPG file as the source file.

PPS I am using ExifTool 10.02 on OS X 10.8.5.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2838
Re: Copy GPS coord tags - Wrong Hemisphere!
« Reply #1 on: March 07, 2016, 09:55:53 PM »
Add -g1 to last command to see the source of the various GPS tags.

The most common tags will be under the GPS section, which is part of the EXIF block.  Unfortunately, those tags are unsigned, which means you have to check the GPSLongitudeRef and GPSLatitudeRef tags to figure out the hemisphere.  There are also the Composite tags, where ExifTool which will figure out the details for you.  Less often used are XMP GPS tags.  These can be signed, so they don't necessarily require Ref tags.

If you add the -g1 to your commands, I'm guessing that your Mov file has XMP GPS tags.  When you copy those to the THM file, the tags are probably being copied to the EXIF GPS tags.  But since EXIF GPS are unsigned, you lose the negative part.

The quick and easy solution, if all your files are going to have a negative Longitude (western hemisphere), you can just set them all to -GPSLongitudeRef=West

If you don't necessarily know if you'll have a negative Longitude or Latitude, you'll want to download the main distribution file.  In it, you'll find a file called xmp2gps.args.  You can use that to copy the GPS tags and it'll fill out the Ref tags for you.  Your command would be something like this:
exiftool -tagsfromfile IMG_1748.MOV -@ xmp2gps.args IMG_1748.THM


Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mpollack

  • Newbie
  • *
  • Posts: 9
Re: Copy GPS coord tags - Wrong Hemisphere!
« Reply #2 on: March 08, 2016, 02:01:43 AM »
Thanks for your reply StarGeek. This is more complicated than I realized. I took your advice and added the -g1 to the last command and it produced the following:

$ exiftool -gps:all -a -gpslatitude -gpslongitude -GPSLongitudeRef -GPSLatitudeRef -n IMG_1748.* -g1
======== IMG_1748.MOV
---- Composite ----
GPS Latitude                    : 37.316
GPS Longitude                   : -122.0599
======== IMG_1748.THM
---- GPS ----
GPS Version ID                  : 2 3 0 0
GPS Latitude                    : 37.316
GPS Latitude                    : 37.316
GPS Longitude                   : 122.0599
GPS Longitude                   : 122.0599
GPS Altitude Ref                : 0
GPS Altitude                    : 93.751


Somehow ExifTool is smart enough to create composite tags for the MOV file's GPS coordinates. Do you know how I can find out what metadata it is using to create the composites?  I looks like the EXIF:GPS block is empty, and no separate XMP file exists. So where else could the information be?

I will try using the xmp2gps.args file tomorrow. That sounds like it might be the best solution, after all.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15224
    • ExifTool Home Page
Re: Copy GPS coord tags - Wrong Hemisphere!
« Reply #3 on: March 08, 2016, 09:41:43 AM »
The Composite tags documentation lists all of the composite tags and the tags they are derived from.

It looks like the THM is missing the mandatory reference directions.  If you want, you can add these back again from the MOV files:

exiftool -tagsfromfile %d%f.MOV "-gpslatituderef<gpslatitude" "-gpslongituderef<gpslongitude" -ext thm DIR

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

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2838
Re: Copy GPS coord tags - Wrong Hemisphere!
« Reply #4 on: March 09, 2016, 05:33:20 PM »
Cool, I did not know that you could set the Ref values from gpslatitude and gpslongitude.

And now I know that the Quicktime gps values aren't stored in gpslatitude and gpslongitude.  I sat that looking at the results for mpollack's Mov file and couldn't figure it out.  I should have checked out the Composite tag docs.

Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mpollack

  • Newbie
  • *
  • Posts: 9
Re: Copy GPS coord tags - Wrong Hemisphere!
« Reply #5 on: March 10, 2016, 02:44:56 AM »
Thank you, both, StarGeek and Phil. I learned something new, and with your help, I was able to get things working.