ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: nkdevgeek on January 28, 2022, 10:40:34 AM

Title: Geotagging using CSV log file format
Post by: nkdevgeek on January 28, 2022, 10:40:34 AM
Hello,
I am trying to use the GPS csv log file to geotag a few photos (JPG files) and not able to get it to work. Could someone please help.

Exiftool version: 12.39 OS: Windows 11. Executing exiftool using Powershell. I am using the exiftool.exe (renamed from exiftool(-k).exe).

Below is the output:

PS C:\CanonEOSRP Pictures\2022_01_27> exiftool -s -G -DateTimeOriginal -a .\IMG_0715.JPG
[EXIF]          DateTimeOriginal                : 2022:01:27 21:53:25
PS C:\CanonEOSRP Pictures\2022_01_27> type .\exifgpstrackb.csv
GPSDateTime,GPSLatitude,GPSLongitude,GPSLatitudeRef,GPSLongitudeRef,GPSAltitude
2022:01:28 03:56:17,43 04 28.889,89 23 2.991,North,West,326 m
PS C:\CanonEOSRP Pictures\2022_01_27> exiftool -geotag .\exifgpstrackb.csv .\IMG_0715.JPG
Warning: No track points found in GPS file '.\exifgpstrackb.csv' in File:Geotag (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv) - ./IMG_0715.JPG
Warning: No writable tags set from ./IMG_0715.JPG
    0 image files updated


What am I doing incorrect here? Can someone please help?

Thanks in advance.

Best Wishes
-Neeraj
Title: Re: Geotagging using CSV log file format
Post by: StarGeek on January 28, 2022, 11:14:30 AM
This is most likely Geotag Troubleshooting #3 (https://www.sno.phy.queensu.ca/~phil/exiftool/geotag.html#TR3), a problem with the time zone difference.

The time stamps in the file and the csv indicate a 6 hour difference.  Is this the same time zone that your computer is set for?

Try running your command with the -v2 option (https://exiftool.org/exiftool_pod.html#v-NUM--verbose).  There will be a listing for GPS track start and GPS track end.  Following that there will be a listing for Geotime value.  This is the value that exiftool thinks is the time for the file.  If the time zone isn't correct, you'll need to properly adjust the values using the Geosync tag, e.g. '-Geosync<$DateTimeOriginal -07:00.
Title: Re: Geotagging using CSV log file format
Post by: Phil Harvey on January 28, 2022, 11:16:49 AM
Hi Neeraj,

This should work.  I tested here (on my Mac) by cutting and pasting your csv file, and it works fine (although the file wasn't updated because the timestamp was too far away from your track):

> cat a.csv
GPSDateTime,GPSLatitude,GPSLongitude,GPSLatitudeRef,GPSLongitudeRef,GPSAltitude
2022:01:28 03:56:17,43 04 28.889,89 23 2.991,North,West,326 m
> exiftool a.jpg -geotag a.csv -v3
Argument "-Geotime<DateTimeOriginal#" is assumed
CSV column 'DateTime' is datetime
CSV column 'Latitude' is lat
CSV column 'Longitude' is lon
CSV column 'LatitudeRef' is latref
CSV column 'LongitudeRef' is lonref
CSV column 'Altitude' is alt
Loaded 1 points from CSV-format GPS track log file 'a.csv'
  GPS track start: 2022:01:28 03:56:17.000 UTC
  GPS track end:   2022:01:28 03:56:17.000 UTC
Writing File:Geotag
======== a.jpg
Setting new values from a.jpg
  Geotime value:   1979:07:30 23:22:00.000 UTC (local timezone is -04:00)
  Track start:     2022:01:28 03:56:17.000 UTC
Time is too far before track in File:Geotime (ValueConvInv)
Warning: Time is too far before track in File:Geotime (ValueConvInv) - a.jpg
Warning: No writable tags set from a.jpg
Nothing changed in a.jpg
    0 image files updated
    1 image files unchanged


Could you attach your CSV file so we can see if there is something wrong with the way it is formatted?

- Phil

Edit: Cross post with StarGeek.  This isn't just a timezone problem because no track points are being loaded from the csv file.
Title: Re: Geotagging using CSV log file format
Post by: nkdevgeek on January 28, 2022, 12:54:44 PM
Thank you for your quick responses, @StarGeek and @Phil.
Your responses gave me very important pointers. The -v3 option showed me that special characters had somehow sneaked into the CSV file before the datetime value. I nuked the file that I was using and manually recreated a new CSV file and everything worked like a charm!
I have various text editors and none were showing the special characters even when 'show all characters' option in these editors was enabled. The output of -v3 option showed the special characters!

The power of the -v3 option!

I am attaching the clean working csv file if anyone wants to use it!

Thanks again Phil and StarGeek. Really appreciate it.

Best wishes,
Neeraj

Title: Re: Geotagging using CSV log file format
Post by: Phil Harvey on January 28, 2022, 01:31:24 PM
What exactly where these characters?  If it was a UTF-8 byte order mark (0xef 0xbb 0xbf), then I could patch ExifTool to allow this.

- Phil
Title: Re: Geotagging using CSV log file format
Post by: StarGeek on January 28, 2022, 02:37:36 PM
Quote from: Phil Harvey on January 28, 2022, 11:16:49 AMEdit: Cross post with StarGeek.  This isn't just a timezone problem because no track points are being loaded from the csv file.

Admittedly, I was giving the answer that is the solution for about 75% of all GPS track related question. :)
Title: Re: Geotagging using CSV log file format
Post by: nkdevgeek on January 28, 2022, 02:53:14 PM
Below is the output with the errant file. Notice the special characters before GPSDateTime on the third line.

I am also attaching the errant CSV file if you can decipher the special characters. Yes, indeed those were leading UTF-8 byte order mark. See the attached screenshot below from my hex editor. I am also attaching the file for your reference. (Phil - fabulous at troubleshooting).


PS C:\CanonEOSRP Pictures\2022_01_27> exiftool -geotag .\exifgpstrackb.csv .\IMG_0716.JPG -v3
Argument "-Geotime<DateTimeOriginal#" is assumed
CSV column 'GPSDateTime' ignored
CSV column 'Latitude' is lat
CSV column 'Longitude' is lon
CSV column 'LatitudeRef' is latref
CSV column 'LongitudeRef' is lonref
CSV column 'Altitude' is alt
Loaded 0 points from CSV-format GPS track log file '.\exifgpstrackb.csv'
No track points found in GPS file '.\exifgpstrackb.csv' in File:Geotag (ValueConvInv)
Warning: No track points found in GPS file '.\exifgpstrackb.csv' in File:Geotag (ValueConvInv)
======== ./IMG_0716.JPG
Setting new values from ./IMG_0716.JPG
Tag 'GPSPitch' is not defined
Tag 'GPSRoll' is not defined
GPS track is empty in File:Geotime (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv) - ./IMG_0716.JPG
Warning: No writable tags set from ./IMG_0716.JPG
Nothing changed in ./IMG_0716.JPG
    0 image files updated
    1 image files unchanged


I hope this helps. Great if a patch can take care of it.

Best wishes
-Neeraj
Title: Re: Geotagging using CSV log file format
Post by: Phil Harvey on January 28, 2022, 07:45:12 PM
Hi Neeraj,

Thanks.  ExifTool 12.40 will be able to handle a UTF-8 BOM at the start of a CVS -geotag file.

- Phil