Garmin FIT files for Geotagging

Started by KuchKuch, April 16, 2022, 10:13:10 AM

Previous topic - Next topic

KuchKuch

I know that Garmin FIT (Flexible and Interoperable Data Transfer) files aren't supported by ExifTool for Geotagging, however I have been using my Garmin Edge 530 to geotag my photos. I have been doing this by using Garmin Basecamp to convert the Garmin FIT files recorded by my Edge 530 to GPX. I recently noticed that my FIT files record the compass direction, however I don't believe this is exported in the GPX file produced by Basecamp (or any file supported by Basecamp). Therefore, I thought I would try and make my own ExifTool CSV file that I can use for geotagging instead from my Garmin FIT file.

However there are two issues I'm having:
1)   I don't know how to easily convert the Latitude and Longitude points my FIT file shows into the EXIF format that is required by ExifTool. It shows them as a decimal format – for example Latitude as "53.2734" and Longitude "-7.77832031"
2)   I believe the GPSTrack column is the column that is required to show the shooting direction of a photo. My FIT file shows this as "336.6° true", but I'm not sure if this is the format required to be used in a ExifTool CSV file.

Any suggestions on the above?

StarGeek

Quote from: KuchKuch on April 16, 2022, 10:13:10 AM
1)   I don't know how to easily convert the Latitude and Longitude points my FIT file shows into the EXIF format that is required by ExifTool. It shows them as a decimal format – for example Latitude as "53.2734" and Longitude "-7.77832031"

Exiftool reads decimal GPS coordinates without having to convert them to any other format.  See FAQ #14.

Quote2)   I believe the GPSTrack column is the column that is required to show the shooting direction of a photo. My FIT file shows this as "336.6° true", but I'm not sure if this is the format required to be used in a ExifTool CSV file.

The thing to remember about the GPS tags that are part of the EXIF block is that they are split into two separate tags.  The actual number and the reference direction.  For coordinates, you can directly pass the value to both tags.
C:\>exiftool -P -overwrite_original -GPSLatitude=53.2734 -GPSLatitudeRef=53.2734 -GPSLongitude=-7.77832031 -GPSLongitudeRef=-7.77832031 y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -GPS* y:\!temp\Test4.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 53 deg 16' 24.24"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 7 deg 46' 41.95"
[Composite]     GPSLatitude                     : 53 deg 16' 24.24" N
[Composite]     GPSLongitude                    : 7 deg 46' 41.95" W
[Composite]     GPSPosition                     : 53 deg 16' 24.24" N, 7 deg 46' 41.95" W


The other GPS tags are not as flexible and need to be more exacting when setting.  You can't set them to "336.6° true", they need to be set to the number and the reference need to be set to T or M. True or Magnetic will also work
C:\>exiftool -P -overwrite_original -GPSImgDirection=336.6 -GPSImgDirectionRef=True y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -GPS* y:\!temp\Test4.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 53 deg 16' 24.24"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 7 deg 46' 41.95"
[GPS]           GPSImgDirectionRef              : True North
[GPS]           GPSImgDirection                 : 336.6
[Composite]     GPSLatitude                     : 53 deg 16' 24.24" N
[Composite]     GPSLongitude                    : 7 deg 46' 41.95" W
[Composite]     GPSPosition                     : 53 deg 16' 24.24" N, 7 deg 46' 41.95" W


In a csv file, you just need to make sure the column header is the name of the tag you want to write.  So your CSV files should be along these lines.  Order doesn't matter and GPSVersionID can be dropped as that will automatically be written by exiftool.
C:\>exiftool -gps* -csv -e -n y:\!temp\Test4.jpg
SourceFile,GPSVersionID,GPSLatitudeRef,GPSLatitude,GPSLongitudeRef,GPSLongitude,GPSImgDirectionRef,GPSImgDirection
y:/!temp/Test4.jpg,2 3 0 0,N,53.2734,W,7.77832031001944,T,336.6


If you write to the XMP GPS tags, there is no reference tag for the coordinates and you would write the full value directly to the tag
C:\>exiftool -G1 -a -s -XMP:gps* -csv -n y:\!temp\Test4.jpg
SourceFile,XMP-exif:GPSImgDirection,XMP-exif:GPSImgDirectionRef,XMP-exif:GPSLatitude,XMP-exif:GPSLongitude,XMP-exif:GPSVersionID
y:/!temp/Test4.jpg,336.6,T,53.2734,-7.77832031,2.3.0.0
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

#2
Thanks for this.

I tried to use the attached CSV and got the following error message

Warning: No track points found in GPS file 'c:\gps logs\track.csv' in File:Geotag (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv) - c:/images/test.jpg
Warning: No writable tags set from c:/images/test.jpg


Any idea whats wrong? I should add that "GPSDateTime" was set to the exact second the photo was taken.

StarGeek

Your file works correctly here
C:\>exiftool -P -overwrite_original -geotag Y:\!temp\ccc\Track.csv y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -e -DateTimeOriginal -gps* y:\!temp\Test4.jpg
[ExifIFD]       DateTimeOriginal                : 2022:04:16 10:00:10
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 53 deg 16' 24.24"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 7 deg 46' 41.95"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 89.40000153 m
[GPS]           GPSTimeStamp                    : 17:00:10
[GPS]           GPSDateStamp                    : 2022:04:16


So the problem is probably Troubleshooting #2 or #3.

The GPSDateTime in the CSV needs to be in UTC and by default exiftool will use the DateTimeOriginal tag, which is supposed to be local time where the image was shot, and the computer's local time zone, because time zone data isn't always in the file.  If you look at the above output, you can see in my case the DateTimeOriginal is 7 hours earlier than the GPS time because I'm in time zone -07:00.

If the image time is correct but in a different time zone, then you need to make sure Geotime is set correctly.  For example, if my images was taken in New York (-04:00 time zone) but I'm editing at home (-07:00), then my command would have adjust to the correct time zone
exiftool -P -overwrite_original -geotag Y:\!temp\ccc\Track.csv "-Geotime<$DateTimeOriginal -04:00" y:\!temp\Test4.jpg

Also take note that the GPS CSV format file does not read the GPSImgDirection/GPSImgDirectionRef data, so you'll need to add that data some other way.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

The DateTimeOriginal tag definitely matches what is on the CSV file. The timezone isn't an issue either.

Reading up on other posts in the forum I believe my ExifTool CSV was in the wrong format, so I have corrected it in the attached file. This doesn't include the GPSImgDirection/GPSImgDirectionRef data as I'm still getting the same error in Post 3, so I'm clearly doing something wrong.

StarGeek

Quote from: KuchKuch on April 16, 2022, 06:19:08 PM
The DateTimeOriginal tag definitely matches what is on the CSV file. The timezone isn't an issue either.

It should not match what's in the CSV unless you are in +00:00 time zone.  The time in the CSV should be UTC and the time in the file should be local.

QuoteReading up on other posts in the forum I believe my ExifTool CSV was in the wrong format, so I have corrected it in the attached file.

The format was fine, as shown by my example using your file.

Run your command but add the -v2 option.  In the output there will be 2 lines for the gps track's time and one for each file.  Example:
Loaded 1 points from CSV-format GPS track log file 'Y:\!temp\ccc\Track.csv'
  GPS track start: 2022:04:16 17:00:10.000 UTC
  GPS track end:   2022:04:16 17:00:10.000 UTC
Writing File:Geotag
======== y:/!temp/Test4.jpg
Setting new values from y:/!temp/Test4.jpg
  Geotime value:   2022:04:16 17:00:10.000 UTC (local timezone is -07:00)


The "Geotime value" line should be between the "GPS track start/end" timepoints.  If it is not, then the time in the file is incorrect.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

I don't believe timezone is an issue. To clarify, I'm in the timezone BST, which is one hour ahead of UTC. In the track I am trying to load, the GPSDateTime has values from 09:08:15 to 09:12:17. The photo I am testing for this purpose was taken at 10:09:31 BST, which means that it should be looking for a GPSDateTime at 09:09:31, which is in the track.

I.'ve tried to run the command with the -2 option and got the following error:

Argument "-Geotime<DateTimeOriginal#" is assumed
Loaded 0 points from unknown-format GPS track log file 'track.csv'
Warning: No track points found in GPS file 'track.csv' in File:Geotag (ValueConvInv)


Looks like ExifTool has an issue with my track.csv file, I think.

I've attached the exact files I am using - the track file and the photo

StarGeek

What is your exact command and output and what OS?

Your files work correctly here.  Since there is already an embedded gps time stamp in the file, I used that.
C:\>exiftool -P -overwrite_original -geotag Y:\!temp\ccc\track.csv "-Geotime<GPSDateTime" Y:\!temp\ccc\image.jpg
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - Y:/!temp/ccc/image.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -gps* Y:\!temp\ccc\image.jpg
[GPS]           GPSVersionID                    : 2.2.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 53 deg 16' 24.24"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 7 deg 46' 41.95"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 89 m
[GPS]           GPSTimeStamp                    : 09:09:23
[GPS]           GPSProcessingMethod             : CELLID
[GPS]           GPSDateStamp                    : 2022:04:16
[Composite]     GPSAltitude                     : 89 m Above Sea Level
[Composite]     GPSDateTime                     : 2022:04:16 09:09:23Z
[Composite]     GPSLatitude                     : 53 deg 16' 24.24" N
[Composite]     GPSLongitude                    : 7 deg 46' 41.95" W
[Composite]     GPSPosition                     : 53 deg 16' 24.24" N, 7 deg 46' 41.95" W


But it also works when I use DateTimeOriginal and include your +01:00 time zone.  I reset the file to the original before running these commands
C:\>exiftool -G1 -a -s -gps* Y:\!temp\ccc\image.jpg
[GPS]           GPSVersionID                    : 2.2.0.0
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSTimeStamp                    : 09:09:23
[GPS]           GPSProcessingMethod             : CELLID
[GPS]           GPSDateStamp                    : 2022:04:16
[Composite]     GPSDateTime                     : 2022:04:16 09:09:23Z

C:\>exiftool -P -overwrite_original -geotag Y:\!temp\ccc\track.csv "-Geotime<$DateTimeOriginal+01:00" Y:\!temp\ccc\image.jpg
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - Y:/!temp/ccc/image.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -gps* Y:\!temp\ccc\image.jpg
[GPS]           GPSVersionID                    : 2.2.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 53 deg 16' 24.24"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 7 deg 46' 41.95"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 89 m
[GPS]           GPSTimeStamp                    : 09:09:31
[GPS]           GPSProcessingMethod             : CELLID
[GPS]           GPSDateStamp                    : 2022:04:16
[Composite]     GPSAltitude                     : 89 m Above Sea Level
[Composite]     GPSDateTime                     : 2022:04:16 09:09:31Z
[Composite]     GPSLatitude                     : 53 deg 16' 24.24" N
[Composite]     GPSLongitude                    : 7 deg 46' 41.95" W
[Composite]     GPSPosition                     : 53 deg 16' 24.24" N, 7 deg 46' 41.95" W


I did make a mistake in my example above where I put a space in between, "-Geotime<$DateTimeOriginal -04:00" should have been "-Geotime<$DateTimeOriginal-04:00", but
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

I'm on Windows 10 and have my track file in "C:\gps logs" and my photo in "C:\images" and command I run is:

exiftool.exe -geotag "c:\gps logs\track.csv" c:\images

which results in:

Warning: No track points found in GPS file 'c:\gps logs\track.csv' in File:Geotag (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv) - c:/images/image.jpg
Warning: No writable tags set from c:/images/image.jpg
    1 directories scanned
    0 image files updated
    1 image files unchanged


StarGeek

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

Quote from: StarGeek on April 17, 2022, 11:27:15 AM
What is the output if you add -v2?

PS C:\images> exiftool.exe -geotag "c:\gps logs\track.csv" c:\images -v2
Argument "-Geotime<DateTimeOriginal#" is assumed
Loaded 0 points from unknown-format GPS track log file 'c:\gps logs\track.csv'
Warning: No track points found in GPS file 'c:\gps logs\track.csv' in File:Geotag (ValueConvInv)
======== c:/images/image.jpg
Setting new values from c:/images/image.jpg
Warning: GPS track is empty in File:Geotime (ValueConvInv) - c:/images/image.jpg
Warning: No writable tags set from c:/images/image.jpg
Nothing changed in c:/images/image.jpg
    1 directories scanned
    0 image files updated
    1 image files unchanged

StarGeek

Ok, there's obviously something different about the track.csv file you uploaded and the one on your computer.  Because your attached file works correctly after I download it.

Can you zip up the one on your computer and attach the zipped file?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

Quote from: StarGeek on April 17, 2022, 12:15:40 PM
Can you zip up the one on your computer and attach the zipped file?

I'm convinced its the same file, but see the attached.

StarGeek

Quote from: KuchKuch on April 17, 2022, 12:27:35 PMI'm convinced its the same file, but see the attached.

True, I'm grasping at straws at this point.  But the files are identical and both files work correctly here.

What version of exiftool are you using?  Run exiftool -ver to see.  The only other thing I can think of is that you are using an older version, 11.94 or earlier, as version 11.95 - Apr. 23, 2020, had a change to allow more flexibility in csv tracks.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

KuchKuch

Quote from: StarGeek on April 17, 2022, 01:05:00 PM
What version of exiftool are you using?  Run exiftool -ver to see.  The only other thing I can think of is that you are using an older version, 11.94 or earlier, as version 11.95 - Apr. 23, 2020, had a change to allow more flexibility in csv tracks.

I'm using the latest version - 12.4.1.0.