Inverse geotagging and time zones

Started by papa_sierra, October 28, 2024, 06:13:28 PM

Previous topic - Next topic

papa_sierra

Hi,

I used to use GeoSetter on Windows but recently migrated to Mac, so now getting to grips with exiftool command line.

I tend to use three different cameras depending on the situation: iPhone 16, OM System TG-7 and Olympus E-M5. TG-7 has inbuilt GPS but often struggles to get a fix, E-M5 has no GPS. I often run the Olympus OI.Share app on my phone to then geotag photos, but sometimes forget.

In those cases where I end up with some photos having no geotag, I'd like interpolate from those images that have a location by creating a GPX file using inverse geocoding and using that to tag the missing pictures.

I had to modify the suggested gpx.fmt file as it wasn't writing a timestamp to the GPX output, changing gpsdatetime to datetimeoriginal fixed that. However now I am getting local time rather than UTC - how do I get it to write UTC time? The camera seems to have a correct OffsetTime tag. I am trying to simply subtract offset time but this isn't working:
#[BODY]  <time>${datetimeoriginal#-OffsetTime#;DateFmt("%Y-%m-%dT%H:%M:%S%fZ")}</time>
I probably have the $ and # in the wrong places?

Thanks
papa_sierra

Phil Harvey

The necessary gymnastics is not for the faint of heart:

${datetimeoriginal#;my $tz=$self->GetValue("OffsetTimeOriginal");$tz=~tr/-+/+-/;ShiftTime($tz);DateFmt("%Y-%m-%dT%H:%M:%S%fZ")}

Here I used OffsetTimeOriginal instead of OffsetTime becaue this is the one that corresponds to DateTimeOriginal.

The GetValue method must be used to get the value of another tag from inside an advanced formatting expression.  The ShiftTime helper function is used to shift the time, but first I had to change the sign by translating - to + and visa versa.

- 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 ($).

StarGeek

Alternatively, you could go ahead and fix the GPS time stamps first. Assuming that OffsetTimeOriginal is set, you could use this

exiftool '-GPS*Stamp<SubSecDateTimeOriginal' /path/to/files/

Then you could use the unedited gpx.fmt file.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

...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 ($).

papa_sierra

Thank you both for the quick and helpful replies!
To make sure I understand this syntax correctly:
exiftool '-GPS*Stamp<SubSecDateTimeOriginal' /path/to/files/A few questions:
  • Is the * in GPS*Stamp a clever way of changing both GPSDateStamp and GPSTimeStamp?
  • What does SubSecDateTimeOriginal mean? Why not just DateTimeOriginal
  • How do time zones come into this? Will the above command take them into account automatically, or will it set GPS time to local time unless I make a further adjustment?

Thanks & Best Regards
papa_sierra

Phil Harvey

Quote from: papa_sierra on October 29, 2024, 06:55:25 AM1. Is the * in GPS*Stamp a clever way of changing both GPSDateStamp and GPSTimeStamp?

Yes.

Quote2. What does SubSecDateTimeOriginal mean? Why not just DateTimeOriginal

See the Composite tags.

Quote3. How do time zones come into this? Will the above command take them into account automatically, or will it set GPS time to local time unless I make a further adjustment?

StarGeek's command will set GPSDateTime correctly as long as DateTimeOriginal and OffsetTimeOriginal exist in the file.

- 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 ($).

StarGeek

Because I like to be complete, some more details for anyone who comes across this in the future

Quote from: papa_sierra on October 29, 2024, 06:55:25 AMIs the * in GPS*Stamp a clever way of changing both GPSDateStamp and GPSTimeStamp?

From the docs on the -TAG[+-^]=[VALUE] option
QuoteThe wildcards * and ? may be used in tag names to assign the same value to multiple tags.

QuoteWhat does SubSecDateTimeOriginal mean? Why not just DateTimeOriginal
There are three SubSec Composite tags(SubSecCreateDate/SubSecDateTimeOriginal/SubSecModifyDate), one for each of the three main EXIF date/time tags. Because the EXIF date/time tags are split into three separate tags (main date/time, time zone, and subseconds), these three tags will combine the all three of the corresponding tags into a single value, which is useful for copying data, such as in this case.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).