ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Happy Hobo on December 23, 2022, 09:10:43 PM

Title: GPS Formatting
Post by: Happy Hobo on December 23, 2022, 09:10:43 PM
With -c "%.6f", I get this: 42.467761 N, 2.447175 W

With -c "%+.6f", I get this: +42.467761, -2.447175

Is there a way for me to get 42.467761, -2.447175 ?
Title: Re: GPS Formatting
Post by: Phil Harvey on December 23, 2022, 09:26:57 PM
I think you mean -c "%+.6f for your second command.

Generally one uses -n for numerical output, but this gives the full precision.

However, there are other ways to deal with this depending on what output formatting you are using.  With -p you could use the advanced formatting feature.

Alternatively you could apply a blunt instrument to remove a leading "+" from all tag values:

exiftool -api filter="s/^\+//" ...

which will filter GPSLatitude and GPSLongitude, but not the 2nd coordinate of GPSPosition.  I don't know what options you are using.

- Phil
Title: Re: GPS Formatting
Post by: Happy Hobo on December 23, 2022, 10:30:22 PM
Yes, copy/paste, but I was sure I had added the plus in.  The output is a .gpx file with a -p template.  Changing the command to
  exiftool -c "%+.6f"            \
           -api filter="s/^\+//" \
           -p ~/bin/gpxl.fmt     \
           -userparam name="$3"  \
           -userparam desc="$4"   $(ls | sort)  >  /tmp/${2}-l.gpx
worked perfectly.

The latest script and templates are attached for anyone interested.
Title: Re: GPS Formatting
Post by: Phil Harvey on December 24, 2022, 07:03:23 AM
OK.  Perhaps a better way to do this is to drop the -c option and revise your -p format file to use expressions like this:

${gpslatitude#;$_=sprintf("%.6f",$_)}

- Phil
Title: Re: GPS Formatting
Post by: Happy Hobo on August 14, 2023, 02:40:00 PM
Quote from: Phil Harvey on December 24, 2022, 07:03:23 AM${gpslatitude#;$_=sprintf("%.6f",$_)}
That appears to work (without -c) but
#[BODY]        <ele>${gpsaltitude#;$_=sprintf("%.1f",$_)}</ele>
on the next line creates precisions from one digit to six.
Title: Re: GPS Formatting
Post by: Phil Harvey on August 21, 2023, 09:05:43 AM
You want 1 digit after the decimal point, or 1 digit precision?

For 1 digit precision use "%.1g" instead of "%.1f".  But it will switch to exponential format if the number is too high.

- Phil