Geotag using data sourced from a GPX file: specifying the lookup timestamp

Started by stephenhartley, June 05, 2017, 10:53:50 AM

Previous topic - Next topic

stephenhartley

I'm attempting to geotag a (Nikon raw) image file with GPS location sourced from a GPX file, following the instructions given in the exiftool examples here: https://exiftool.org/geotag.html#Examples

QuoteGeotag an image with the GPS position for a specific time. (Note that the Geotag tag must be assigned before Geotime for the GPS data to be available when Geotime is set):

exiftool -geotag t.log -geotime="2009:04:02 13:41:12-05:00" a.jpg


Working in the bash shell on a Mac for all examples, issuing the following works as (I) expected:

exiftool -v2 -geotag=DATETIMEONLY '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF
exiftool -v2 -geotag 2017-06-04T135430Z.gpx '-geotime<GPSDateTime' DSC_8893.NEF


However, if I attempt to specify a "literal" time string rather than reading this value from the GPSDateTime tag, the command errors:

exiftool -v2 -geotag=DATETIMEONLY '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF
exiftool -v2 -geotag 2017-06-04T135430Z.gpx '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF

Warning: GPS track is empty in File:Geotime (ValueConvInv)

Two questions arise:

1. Is this is the intended way of achieving this result, or am I making things over-complicated?
2. What am I doing wrong in the "time string" method?  I have specified Zulu-time, so I think I am correct in assuming that my computer should not be introducing timezone issues.  I've attached the verbose shell output from both approaches below, as well as the relevant snippet from the GPX file.

Thanks in advance,

Steve


Peters-iMac:originals steve$ exiftool -v2 -geotag=DATETIMEONLY '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF
Geotagging date/time only
Writing File:Geotag
  Geotime value:   2017:06:04 13:54:25.000 UTC
Deleting MIE-GPS:GPSLatitude
Deleting XMP-exif:GPSLatitude
Deleting GPS:GPSLatitude
Deleting MIE-GPS:GPSLongitude
Deleting XMP-exif:GPSLongitude
Deleting GPS:GPSLongitude
Deleting MIE-GPS:GPSAltitude
Deleting XMP-exif:GPSAltitude
Deleting GPS:GPSAltitude
Deleting XMP-exif:GPSAltitudeRef
Deleting GPS:GPSAltitudeRef
Deleting GPS:GPSLatitudeRef
Deleting GPS:GPSLongitudeRef
Writing GPS:GPSDateStamp
Writing GPS:GPSTimeStamp
Writing XMP-exif:GPSDateTime if tag exists
======== DSC_8893.NEF
Rewriting DSC_8893.NEF...
  Editing tags in: File GPS IFD0 MIE-GPS TIFF XMP
  Creating tags in: File GPS IFD0 TIFF
  FileType = NEF
  FileTypeExtension = NEF
  MIMEType = image/x-nikon-nef
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting ExifIFD
  Rewriting MakerNoteNikon
  Rewriting PreviewIFD
  Rewriting VRInfo
  Rewriting AFInfo
  Rewriting ShotInfoD80
  Rewriting ColorBalance02
  Rewriting LensData0201
  Rewriting FlashInfo0100
  Rewriting MultiExposure
  Creating GPS
    + GPS:GPSVersionID = '2 3 0 0' (mandatory)
    + GPS:GPSTimeStamp = '13 54 25'
    + GPS:GPSDateStamp = '2017:06:04'
  Copying 2 image data blocks
    1 image files updated
   
   
   
Peters-iMac:originals steve$ exiftool -v2 -geotag 2017-06-04T135430Z.gpx '-geotime<GPSDateTime' DSC_8893.NEF
Loaded 206 points from XML-format GPS track log file '2017-06-04T135430Z.gpx'
  GPS track start: 2017:06:04 13:54:25.000 UTC
  GPS track end:   2017:06:04 18:35:04.000 UTC
Writing File:Geotag
======== DSC_8893.NEF
Setting new values from DSC_8893.NEF
  Geotime value:   2017:06:04 13:54:25.000 UTC
Writing MIE-GPS:GPSLatitude
Writing XMP-exif:GPSLatitude if tag exists
Writing GPS:GPSLatitude
Writing MIE-GPS:GPSLongitude
Writing XMP-exif:GPSLongitude if tag exists
Writing GPS:GPSLongitude
Writing MIE-GPS:GPSAltitude
Writing XMP-exif:GPSAltitude if tag exists
Writing GPS:GPSAltitude
Writing XMP-exif:GPSAltitudeRef if tag exists
Writing GPS:GPSAltitudeRef
Writing GPS:GPSLatitudeRef
Writing GPS:GPSLongitudeRef
Writing GPS:GPSDateStamp
Writing GPS:GPSTimeStamp
Writing XMP-exif:GPSDateTime if tag exists
Rewriting DSC_8893.NEF...
  Editing tags in: File GPS IFD0 MIE-GPS TIFF XMP
  Creating tags in: File GPS IFD0 MIE-GPS TIFF
  FileType = NEF
  FileTypeExtension = NEF
  MIMEType = image/x-nikon-nef
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting ExifIFD
  Rewriting MakerNoteNikon
  Rewriting PreviewIFD
  Rewriting VRInfo
  Rewriting AFInfo
  Rewriting ShotInfoD80
  Rewriting ColorBalance02
  Rewriting LensData0201
  Rewriting FlashInfo0100
  Rewriting MultiExposure
  Rewriting GPS
    + GPS:GPSLatitudeRef = 'N'
    + GPS:GPSLatitude = '51 26 4.94520000001097'
    + GPS:GPSLongitudeRef = 'W'
    + GPS:GPSLongitude = '0 10 4.1268'
    + GPS:GPSAltitudeRef = '0'
    + GPS:GPSAltitude = '29'
    - GPS:GPSTimeStamp = '13 54 25'
    + GPS:GPSTimeStamp = '13 54 25'
    - GPS:GPSDateStamp = '2017:06:04'
    + GPS:GPSDateStamp = '2017:06:04'
  Copying 2 image data blocks
    1 image files updated



Peters-iMac:originals steve$ exiftool -restore_original -ext NEF .
    1 directories scanned
    7 image files found
    1 image files restored from original



Peters-iMac:originals steve$ exiftool -v2 -geotag=DATETIMEONLY '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF
Geotagging date/time only
Writing File:Geotag
  Geotime value:   2017:06:04 13:54:25.000 UTC
Deleting MIE-GPS:GPSLatitude
Deleting XMP-exif:GPSLatitude
Deleting GPS:GPSLatitude
Deleting MIE-GPS:GPSLongitude
Deleting XMP-exif:GPSLongitude
Deleting GPS:GPSLongitude
Deleting MIE-GPS:GPSAltitude
Deleting XMP-exif:GPSAltitude
Deleting GPS:GPSAltitude
Deleting XMP-exif:GPSAltitudeRef
Deleting GPS:GPSAltitudeRef
Deleting GPS:GPSLatitudeRef
Deleting GPS:GPSLongitudeRef
Writing GPS:GPSDateStamp
Writing GPS:GPSTimeStamp
Writing XMP-exif:GPSDateTime if tag exists
======== DSC_8893.NEF
Rewriting DSC_8893.NEF...
  Editing tags in: File GPS IFD0 MIE-GPS TIFF XMP
  Creating tags in: File GPS IFD0 TIFF
  FileType = NEF
  FileTypeExtension = NEF
  MIMEType = image/x-nikon-nef
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting ExifIFD
  Rewriting MakerNoteNikon
  Rewriting PreviewIFD
  Rewriting VRInfo
  Rewriting AFInfo
  Rewriting ShotInfoD80
  Rewriting ColorBalance02
  Rewriting LensData0201
  Rewriting FlashInfo0100
  Rewriting MultiExposure
  Creating GPS
    + GPS:GPSVersionID = '2 3 0 0' (mandatory)
    + GPS:GPSTimeStamp = '13 54 25'
    + GPS:GPSDateStamp = '2017:06:04'
  Copying 2 image data blocks
    1 image files updated



Peters-iMac:originals steve$ exiftool -v2 -geotag 2017-06-04T135430Z.gpx '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF
Warning: GPS track is empty in File:Geotime (ValueConvInv)
Loaded 206 points from XML-format GPS track log file '2017-06-04T135430Z.gpx'
  GPS track start: 2017:06:04 13:54:25.000 UTC
  GPS track end:   2017:06:04 18:35:04.000 UTC
Writing File:Geotag
======== DSC_8893.NEF
Nothing changed in DSC_8893.NEF
    0 image files updated
    1 image files unchanged



Quote<?xml version="1.0"?>
<gpx
version="1.0"
creator="GPX Master.app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
  <time>2017-06-04T13:54:30Z</time>
  <trk>
    <name>GPX Master Track - 4 Jun 2017, 14:54</name>
    <trkseg>
      <trkpt lat="51.434707" lon="-0.167813">
        <ele>29</ele>
        <time>2017-06-04T13:54:25Z</time>
      </trkpt>
      <trkpt lat="51.434766" lon="-0.167906">
        <ele>27</ele>
        <time>2017-06-04T13:54:30Z</time>
      </trkpt>
      <trkpt lat="51.434747" lon="-0.167857">
        <ele>28</ele>
        <time>2017-06-04T13:54:31Z</time>
      </trkpt>
      <trkpt lat="51.434812" lon="-0.167752">
        <ele>27</ele>
        <time>2017-06-04T13:54:31Z</time>
      </trkpt>
      <trkpt lat="51.434764" lon="-0.167819">
        <ele>29</ele>
        <time>2017-06-04T13:54:32Z</time>
      </trkpt>
      <trkpt lat="51.434750" lon="-0.167830">
        <ele>28</ele>
        <time>2017-06-04T13:54:34Z</time>
      </trkpt>
      <trkpt lat="51.434742" lon="-0.167814">
        <ele>28</ele>
        <time>2017-06-04T13:54:35Z</time>
      </trkpt>

Phil Harvey

First, I can't reproduce the problem you are seeing.  What version of ExifTool are you using?

Second, you don't need to set use the DATETIMEONLY feature if you are later setting the GPS position from a track.

Third, it seems I have introduced a problem in the -geotag option that causes the order of operations to be different if the "=" sign is not used.

So try just this:

exiftool -v2 -geotag=2017-06-04T135430Z.gpx '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF

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

stephenhartley

Hi Phil, Thanks for looking at this so quickly...!

Quote from: Phil Harvey on June 05, 2017, 11:22:42 AM
First, I can't reproduce the problem you are seeing.  What version of ExifTool are you using?

exiftool -ver
10.29


uname -a
Darwin Peters-iMac 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64


Would you recommend I upgrade to a later version of exiftool?

Quote from: Phil Harvey on June 05, 2017, 11:22:42 AM
Second, you don't need to set use the DATETIMEONLY feature if you are later setting the GPS position from a track.

Thanks for confirming - I suspected (and hoped) that might be the case.

Quote from: Phil Harvey on June 05, 2017, 11:22:42 AM
Third, it seems I have introduced a problem in the -geotag option that causes the order of operations to be different if the "=" sign is not used.

So try just this:

exiftool -v2 -geotag=2017-06-04T135430Z.gpx '-geotime=2017:06:04 13:54:25Z' DSC_8893.NEF

Good spot!  Dropping the equals sign does indeed fix it.  Is that a bug then?  If it is, I'm surprised it's not been noticed before, would seem (to me) to be quite a popular use case...

Thanks for your help!

Steve

Phil Harvey

Hi Steve,

You mean adding this equal sign fixed it?  Yes, I'm surprised that this wasn't caught before now, but it is rare for people to specify the time manually like this.  I have updated the geotagging documentation until I can fix this.

No need to update your version.

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

stephenhartley


Phil Harvey

I have just released ExifTool 10.56.  In this version the ordering constraints between Geotag/Geosync and Geotime on the command line have been removed.

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