ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: toc-rox on September 13, 2012, 10:38:27 AM

Title: Formatting of GPS data
Post by: toc-rox on September 13, 2012, 10:38:27 AM
Hi,

I use ExifTool in a tool chain in order to annotate pictures with GPS data (see http://www.easyclasspage.de/pictools/seite-1.html).

Feature request: Is it possible to format the hemisphere in a more flexible way ?

What I want to achieve is something like this (example):
N 51° 48.553
E 007° 17.253

-c FMT (-coordFormat)
Set the print format for GPS coordinates. FMT uses the same syntax as the printf format string.
The specifiers correspond to degrees, minutes and seconds in that order, but minutes and seconds are optional.
For example, the following table gives the output for the same coordinate using various formats:

        FMT                  Output
-------------------    ------------------
"%d deg %d' %.2f"\"    54 deg 59' 22.80"  (default for reading)
"%d %d %.8f"           54 59 22.80000000  (default for copying)
"%d deg %.4f min"      54 deg 59.3800 min
"%.6f degrees"         54.989667 degrees


Notes:
1) To avoid loss of precision, the default coordinate format is different when copying tags using the -tagsFromFile option.
2) If the hemisphere is known, a reference direction (N, S, E or W) is appended to each printed coordinate, but adding a + to the format specifier (ie. %+.6f) prints a signed coordinate instead.

Regards Klaus
Title: Re: Formatting of GPS data
Post by: Phil Harvey on September 13, 2012, 11:13:19 AM
Hi Klaus,

Currently there is no way to do exactly what you want.  The closest you could get is

51° 48.553 N
007° 17.253 E

- Phil
Title: Re: Formatting of GPS data
Post by: toc-rox on September 14, 2012, 04:24:30 AM
Hi Phil,

if you plan an improvement for the GPS position formatting "-c FMT (-coordFormat)", please take an additional formatting option for the hemisphere into account.

Thanks - Klaus
Title: Re: Formatting of GPS data
Post by: ArtMan on October 03, 2012, 02:40:47 PM
Phil,

I'd like to export GPS coordinates in this format: 42.988391, -79.094287

In other words, a minus sign for west longitude or south latitude, but no plus sign for east or north. This is a fairly standard convention among geographers.

This formatting command -c "%.6f" produces output like this: 49.237881 N,0.638462 W

This page http://www.exiftool.org/ExifTool.html (http://www.exiftool.org/ExifTool.html) says "adding a '+' to the format specifier (ie. '%+.6f') prints a signed coordinate instead." (Emphasis mine.)

But when I try  -c "%+.6f", the output is formatted like this — +49.237881 N,+0.638462 W — with an unneeded plus sign in front of latitude, and an incorrect plus sign in front of the West longitude (which should be signed minus), while keeping the correct but redundant N and W directions.

Is there a formatting string I can use to get the results I want?

If not, please consider adding it to a future version of Exiftool — which is a terrific utility for which I thank you!

-ArtMan-
Title: Re: Formatting of GPS data
Post by: Phil Harvey on October 03, 2012, 02:51:56 PM
Hi Artman.  You can use the -n option to do what you want, although the values in GPSPosition will be separated by a space, not a comma.  But you can use -p and the original GPSLatitude/GPSLongitude tags to format this however you want.  Another alternative is a user-defined tag.  But note that only Composite and XMP GPS coordinates are signed.  The EXIF GPS coordinates aren't.

- Phil
Title: Re: Formatting of GPS data
Post by: josh_jones123 on February 06, 2021, 09:53:15 PM
Hello. Very basic question but I have searched and searched and couldn't resolve this myself.

I have GPS data in a CSV file in decimal degrees format with negative latitude for southern hemisphere. Could you please confirm the syntax code for writing these GPS points to my jpeg files? I believe it is the following but it will not display the negative latitude in the metadata:

exiftool -c "%+.gf" dir -csv=filename and directory for csv file

thanks for your help
Title: Re: Formatting of GPS data
Post by: Phil Harvey on February 06, 2021, 09:56:19 PM
You don't need the -c option, but you do need to also write GPSLatitudeRef and GPSLongitudeRef with the same coordinate values (ExifTool will deduced N/S and E/W from the sign of the coordinates).

See FAQ 14 (https://exiftool.org/faq.html#Q14) for more details.

- Phil