ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Alan Clifford on January 04, 2021, 03:15:50 PM

Title: Maybe I can do this with a format file?
Post by: Alan Clifford on January 04, 2021, 03:15:50 PM
Before I delve into format files, the question is at the end  ;D

I want to create a csv file with this format

LATITUDE,LONGITUDE,ALTITUDE,YEAR,MONTH,DAY,HOUR,MIN,SEC
13.079260,-59.586655,23,2019,10,30,17,44,41
13.079260,-59.586655,23,2019,10,30,17,49,22


When I click on the map in Nikonviewnxi, a sidecar file is created that includes latitude and longitude but no gpsdatetime.  But I have already put into the photo

[XMP-exif]      Date/Time Original              : 2019:11:27 14:29:27-04:00

which is copied into the sidecar file.

So I have a datetime and a block of gps data.


[XMP-ast]       GPS Latitude Ref                : 0
[XMP-ast]       GPS Latitude Ref Type           : Long
[XMP-ast]       GPS Latitude                    : 13.2683971683184
[XMP-ast]       GPS Latitude Type               : Double
[XMP-ast]       GPS Longitude Ref               : 3
[XMP-ast]       GPS Longitude Ref Type          : Long
[XMP-ast]       GPS Longitude                   : 59.5746526288986
[XMP-ast]       GPS Longitude Type              : Double
[XMP-ast]       GPS Map Datum                   : WGS-84
[XMP-ast]       GPS Map Datum Type              : Ascii
[Composite]     GPS Latitude                    : 13.2683971683184
[Composite]     GPS Longitude                   : -59.5746526288986
[Composite]     GPS Position                    : 13.2683971683184 -59.5746526288986



The only element missing in the data is altitude but I am prepared to have a zero or dash put intothe csv file and I can manually edit the file.

But there is a problem.  Is there a magic exiftool incantation that will change the date into UTC before I split it into hour,minute,seconds element?

Title: Re: Maybe I can do this with a format file?
Post by: Phil Harvey on January 04, 2021, 03:31:26 PM
Magic incantation:

exiftool -f -p '$gpslatitude#,$gpslongitude#,$gpsaltitude,${xmp-exif:datetimeoriginal;s/([-+].*)//;my $tz=$1;$tz=~tr/-+/+-/;ShiftTime($tz);tr/: /,,/}' FILE

(based on code from this post (https://exiftool.org/forum/index.php?topic=11958.msg64535#msg64535))

- Phil
Title: Re: Maybe I can do this with a format file?
Post by: Alan Clifford on January 04, 2021, 04:11:11 PM
Thanks!

I must have seen that post - it wasn't very long ago.
Title: Re: Maybe I can do this with a format file?
Post by: Alan Clifford on January 04, 2021, 05:26:57 PM
Nearly there.  I'm doing this for the times when I forget to switch on my gps tracker but I know where I've been.

exiftool -config ~/bin/nksc.config -f -p magicincantation.fmt NKSC_PARAM/*.nksc
LATITUDE,LONGITUDE,ALTITUDE,YEAR,MONTH,DAY,HOUR,MIN,SEC
13.2683971683184,-59.5746526288986,-,2019,11,27,18,29,27
13.268387144804,-59.5746543979645,-,2019,11,27,18,09,27
13.2683971683184,-59.5746526288986,-,2019,11,27,18,30,24
13.273386408488,-59.5847958279981,-,2019,11,27,19,19,42


I have a known problem issue with my bash script that uses this csv file and I think I should look at that rather than the magic incantation.  It all stems from the format my original gps device produced and I've made sure there are no leading zeros when translating the logs from more recent devices to this format.

/Users/alan/bin/addstufftojpg.sh: line 248: printf: 09: invalid number

I think bash's printf is interpreting 09 as an invalid octal number.

Title: Re: Maybe I can do this with a format file?
Post by: Phil Harvey on January 04, 2021, 07:42:37 PM
Quite possible.  A leading zero means an octal number in some languages.  If you want to remove leading zeros, add ;s/\b0//g to the formatting expression.

- Phil
Title: Re: Maybe I can do this with a format file?
Post by: Alan Clifford on January 05, 2021, 06:56:19 AM
Thanks Phil.  The help is appreciated.

I decided to removed it in the bash script with expr.