Author Topic: GPS decimal precision  (Read 1939 times)

wywh

  • Sr. Member
  • ****
  • Posts: 116
GPS decimal precision
« on: January 28, 2021, 02:51:20 PM »
It seems as a new feature in Google Maps the user must now crtl-click the location and it is copied at up to 15 decimal precision (previously a spot could be clicked and then copied at the upper left panel with AFAIR less precision).

It seems there is 13 decimal limit that EXIF supports? How is it rounded? Such copied location in exiftool 12.16:

exiftool -m -P -overwrite_original_in_place -GPSLatitude=36.7750521074162 -GPSLatitudeRef=S -GPSLongitude=66.844982461645095 -GPSLongitudeRef=W a.jpg
    1 image files updated

exiftool -a -G1 -s -n -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 36.7750521074139
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 66.8449824615694
[Composite]     GPSLatitude                     : -36.7750521074139
[Composite]     GPSLongitude                    : -66.8449824615694
[Composite]     GPSPosition                     : -36.7750521074139 -66.8449824615694


The input with 13 and 15 decimals is truncated to 13 decimals. Why is it rounded like that? AFAIR decimal degrees are precise and minutes and seconds are rounded or is it vice versa?

36.7750521074162 -> rounded to:
36.7750521074139 -> but would this be correct:
36.7750521074162

66.844982461645095 -> rounded to:
66.8449824615694   -> but would this be correct:
66.8449824616451


BTW GraphicConverter does not paste such copied GPS from Google Maps until it is cropped to 10 decimals or less which is currently clumsy.

- Matti

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18771
    • ExifTool Home Page
Re: GPS decimal precision
« Reply #1 on: January 28, 2021, 03:25:32 PM »
Hi Matti,

66.844982461645095 -> rounded to:
66.8449824615694


You're talking about a difference of 8.4 micrometers here.

- 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: 5862
Re: GPS decimal precision
« Reply #2 on: January 28, 2021, 03:47:14 PM »
Less than that, I think.  This chart gives 8 decimals a precision of 1.1 millimeters.  Scaling down from that would give 13 decimals a precition of 11 nanometres.  Going to 15 would be 110 picometres, about the radius of a gold atom, according to wikipedia.

I'm pretty sure that Google Maps isn't displaying to that level of detail ;)
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.

wywh

  • Sr. Member
  • ****
  • Posts: 116
Re: GPS decimal precision
« Reply #3 on: January 28, 2021, 03:57:42 PM »
You're talking about a difference of 8.4 micrometers here.

Yes I know... I have a spreadsheet where I have saved my often visited places so I can copy those coordinates to images lacking location. I use there 4 decimal GPS which AFAIK is up to 11 meters everywhere which is enough for me (equator 40 075 km / (360 * 10000) = 11.1 m).

But it is the Google Maps that is using so many decimals and I am trying to get the basic facts clear for myself before I suggest that GraphicConverter author modifies his app so that it accepts Google's current numbers in the best possible way.

BTW another related question: What is the best way to paste GPS copied from Google Maps to exiftool? The numbers are copied as '-36.7750521074162, -66.844982461645095' and it is clumsy to break it to Latitude and Longitude and LatitudeRef and LongitudeRef for the command above. Is it possible to paste it as is in some format?

p.s. Thanks for the chart that confirms my calculations :-)

- Matti

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18771
    • ExifTool Home Page
Re: GPS decimal precision
« Reply #4 on: January 28, 2021, 04:14:24 PM »
Hi Matti,

But it is the Google Maps that is using so many decimals and I am trying to get the basic facts clear for myself before I suggest that GraphicConverter author modifies his app so that it accepts Google's current numbers in the best possible way.

The fact is that GPS coordinates are stored as 3 limited-precision rational values in EXIF.  Rounding will occur.

Quote
BTW another related question: What is the best way to paste GPS copied from Google Maps to exiftool? The numbers are copied as '-36.7750521074162, -66.844982461645095' and it is clumsy to break it to Latitude and Longitude and LatitudeRef and LongitudeRef for the command above. Is it possible to paste it as is in some format?

You could do this:

exiftool '-gpslatitude<${coords;s/,.*//}' '-gpslatituderef<${coords;s/,.*//}' '-gpslongitude<${coords;s/.*,//}' '-gpslongituderef<${coords;s/.*,//}' -userparam coords='-36.7750521074162, -66.844982461645095' FILE

- Phil

Edit: Wow.  That was difficult to post the above command line.  For some reason the forum gave an error whenever I tried to post it using double quotes instead of single quotes in the command... I'll have to track this down.

Edit2: It is somehow triggering a modsecurity exception in the server:

[Thu Jan 28 13:25:14.563755 2021] [:error] [pid 31942:tid 3514609886976] [client xx.xx.xx.xx:65425] [client xx.xx.xx.xx] ModSecurity: Warning. Pattern match "(?:\\\\$(?:\\\\((?:\\\\(.*\\\\)|.*)\\\\)|\\\\{.*\\\\})|[<>]\\\\(.*\\\\))" at ARGS:message. [file "/dh/apache2/template/etc/mod_sec3_CRS/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "367"] [id "932130"] [msg "Remote Command Execution: Unix Shell Expression Found"] [data "Matched Data: ${coords s/ .*//} found within ARGS:message: -gpslatitude<${coords s/ .*//}"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "platform-unix"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "exiftool.org"] [uri "/forum/index.php"] [unique_id "YBMrukBf7aRE35nH0df1ZQAAAAE"], referer: https://exiftool.org/forum/index.php?action=post;msg=65321;topic=12091.0

Edit3: Server reconfigured.  Posting problem is fixed now
« Last Edit: January 28, 2021, 04:51:09 PM by Phil Harvey »
...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: 5862
Re: GPS decimal precision
« Reply #5 on: January 28, 2021, 05:22:59 PM »
Edit: Wow.  That was difficult to post the above command line.  For some reason the forum gave an error whenever I tried to post it using double quotes instead of single quotes in the command... I'll have to track this down.

Yeah, I had that problem a couple days ago but didn't try single quotes at the time. Glad to see there was a fix.
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.

wywh

  • Sr. Member
  • ****
  • Posts: 116
Re: GPS decimal precision
« Reply #6 on: January 29, 2021, 02:43:25 PM »
You could do this:

Thanks, but that fails to set the LongitudeRef:

exiftool -P -overwrite_original_in_place '-GPSLatitude<${coords;s/,.*//}' '-GPSLatitudeRef<${coords;s/,.*//}' '-GPSLongitude<${coords;s/.*,//}' '-GPSLongitudeRef<${coords;s/.*,//}' -userParam coords='-36.7750521074162, -66.844982461645095' a.jpg
    1 image files updated

exiftool -a -G1 -s -n -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 36.7750521074139
[GPS]           GPSLongitude                    : 66.8449824615694
[Composite]     GPSLatitude                     : -36.7750521074139
[Composite]     GPSPosition                     : -36.7750521074139 66.8449824615694


- Matti

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 5862
Re: GPS decimal precision
« Reply #7 on: January 29, 2021, 03:58:37 PM »
Try this (space after the comma)
'-GPSLongitudeRef<${coords;s/.*, //}'
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.

wywh

  • Sr. Member
  • ****
  • Posts: 116
Re: GPS decimal precision
« Reply #8 on: January 29, 2021, 05:41:32 PM »
Try this (space after the comma)

Thanks, that works OK (and maybe soon I might be able to compose a similar pattern by myself):

exiftool -P -overwrite_original_in_place '-GPSLatitude<${coords;s/,.*//}' '-GPSLatitudeRef<${coords;s/,.*//}' '-GPSLongitude<${coords;s/.*,//}' '-GPSLongitudeRef<${coords;s/.*, //}' -userParam coords='-36.7750521074162, -66.844982461645095' a.jpg
    1 image files updated

exiftool -a -G1 -s -n -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 36.7750521074139
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 66.8449824615694
[Composite]     GPSLatitude                     : -36.7750521074139
[Composite]     GPSLongitude                    : -66.8449824615694
[Composite]     GPSPosition                     : -36.7750521074139 -66.8449824615694


- Matti