Main Menu

gpsposition format

Started by fager, January 03, 2015, 09:12:42 AM

Previous topic - Next topic

fager

Hi,

I would like to write the GPS information, stored in EXIF information of multiple JPG files to the XMP description field. Afterwards I will use the XMP description information in Adobe Indesign as image caption.

Using this forum and the FAQ's I managed to find this command line:
exiftool "-xmp:description<$gpsposition" *.jpg

This results in an XMP description like:
35 39 14.46480000 N, 139 45 27.50040000 E
I expacted the result to like the command line output: 35 deg 39' 14.46" N, 139 deg 45' 27.50" E

After some reading here I tried:
exiftool -n "-xmp:description<$gpsposition" *.jpg
That result in an XMP description like:
35.654018 139.757639
I'm missing N/S resp. E/W.

Is there any chance to get the gpsposition format look either
35 deg 39' 14.46" N, 139 deg 45' 27.50" E
or
35.654018 N 139.757639 E
?

Thanks in advance for your support!

Phil Harvey

The -c option gives you full control over the coordinate formatting.  Here is the relevant section of the application documentation:

       -c FMT (-coordFormat)
            Set the print format for GPS coordinates.  FMT uses the same syn-
            tax as the "printf" format string.  The specifiers correspond to
            degrees, minutes and seconds in that order, but minutes and sec-
            onds 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 (eg. "%+.6f") prints a signed coordinate instead.

            3) This print formatting may be disabled with the -n option to
            extract coordinates as signed decimal degrees.


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

fager

Hi Phil,

many thanks for your quick replay.

The -c option does the trick; must have missed it scanning the documentation.

Any chance getting a ° into the description?
I tried using HTML Code, without avail:

exiftool "-xmp:description<$gpsposition" -E *.jpg -c "%d&deg;%d'%.2f"\"

Phil Harvey

You should be able to just put whatever character you want direcctly into the -c format string.

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

fager

Hi Phil,

I was using this command
exiftool "-xmp:description<$gpsposition" -E *.jpg -c "%d°%d'%.2f"\"

And I got:
35?39'14.46" N, 139?45'27.50" E

The ° seems to be a special character.

Phil Harvey

Right. So you must use the -charset option to specify the encoding you are using (this defaults to UTF-8 if not specified).  If you are on Windows, it is likely that adding -L will do the trick.

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

fager

Hi Phil,

thanks again.
The following works as desired:
exiftool "-xmp:description<$gpsposition" -L *.jpg -c "%d°%d'%.2f"\"

:)