wtorek, 31 października 2017

Geotagging images with ExifTool

Note: Below it is assumed that ExifTool is used in MS Windows environment.

Download the ExifTool.exe file and place it in some directory (SomeDir)

Open the Command line (go to windows search, type cmd and the window will open)

In the command line window, change directory to SomeDir.

Geotagging photos using GPX log

Photos taken with modern smartphones are already geotagged (if Location option is On.)

If camera is unable to add geocoordinates geotagging is still possible if GPS log is available (registered with some external GPS receiver/logger).

Synchronize photos with GPS log

Download the GPX file from your GPS receiver/logger (exact procedure depends on the type of GPS receiver) to SomeDir.

Take picture of GPS receiver/or any screen displaying accurate time (PC/Smartphone screen for example).

Type in command line:

exiftool -DateTimeOriginal IMG_20171021_113121.jpg 
Date/Time Original : 2017:10:29 11:52:46

So the file was created at 11:52:46 according to DateTimeOriginal tag. Exact time is depicted. and if for example the time depicted (accurate time) is 11:50:19 CET and DateTimeOriginal is 11:52:46 CET, then the time difference is 11:32:46 - 11:50:19 = 2min 27s, ie. accurate time is obtained by substracting 2min 27s from DateTimeOriginal.

All GPS receivers internally use/record UTC time only, even if they diplay local time (cf UTC_offset). Usually the camera internally uses local time. If it is the case one should declare appropriate UTC_offset (otherwise exiftool uses system offset).

Copy all photos to SomeDir.

Type in command line:

exiftool -geosync=-02:27 '-geotime<${DateTimeOriginal}+01:00' -geotag my_gps.log SomeDir

The Geotime tag specifies the point in time for which the GPS position is calculated. -geotime<${DateTimeOriginal}+01:00 means GPS position is calculated according to DateTimeOriginal and it is CET time (+01:00 offset from UTC)

The Geosync tag specifies extra time drift, as explained above.

Generate KML file

Exiftool -p option have to be used to output files in GPX and/or KML.

exiftool -fileOrder gpsdatetime -p gpx.fmt SomeDir > SomeTripPhotos.gpx

or

exiftool -fileOrder gpsdatetime -p kml.fmt SomeDir > SomeTripPhotos.kml

KML files can be imported to Google maps and or Google earth.

Note: If such a map is not displayed locally but upload to some WWW server (http://www.gpsvisualizer.com/ in the case of GPX file for example), photos have to be uploaded to some server first and then URL to photos fixed. Exact procedure depends on which server is used for storing photos.

Example format files

gpx.fmt

#[HEAD]<?xml version="1.0" encoding="utf-8"?>
#[HEAD]<gpx version="1.0"
#[HEAD] creator="ExifTool $ExifToolVersion"
#[HEAD] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
#[HEAD] xmlns="http://www.topografix.com/GPX/1/0"
#[HEAD] xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
#[BODY]<wpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <name>$directory/$filename</name>
#[BODY]  <ele>$gpsaltitude#</ele>
#[BODY]  <desc>$directory/$filename</desc>
#[BODY]  <link href="$directory/$filename"><type>large</type></link>
#[BODY]  <link href="$directory/$filename"><type>thumbnail</type></link>
#[BODY]  <time>$gpsdatetime</time>
#[BODY]</wpt>
#[TAIL]</gpx>

kml.fmt

#[HEAD]<?xml version="1.0" encoding="UTF-8"?>
#[HEAD]<kml xmlns="http://earth.google.com/kml/2.0">
#[HEAD]  <Document>
#[HEAD]    <name>My Photos</name>
#[HEAD]    <open>1</open>
#[HEAD]    <Style id="Photo">
#[HEAD]      <IconStyle>
#[HEAD]        <Icon>
#[HEAD]          <href>http://maps.google.com/mapfiles/kml/pal4/icon38.png</href>
#[HEAD]          <scale>1.0</scale>
#[HEAD]        </Icon>
#[HEAD]      </IconStyle>
#[HEAD]    </Style>
#[HEAD]    <Folder>
#[HEAD]      <name>Waypoints</name>
#[HEAD]      <open>0</open>
#[BODY]      <Placemark>
#[BODY]        <description><![CDATA[<br/><table><tr><td>
#[BODY]        <img src='$directory/$filename'
#[BODY]          width='$imagewidth' height='$imageheight'>
#[BODY]        </td></tr></table>]]></description>
#[BODY]        <Snippet/>
#[BODY]        <name>$filename</name>
#[BODY]        <styleUrl>#Photo</styleUrl>
#[BODY]        <Point>
#[BODY]          <altitudeMode>clampedToGround</altitudeMode>
#[BODY]          <coordinates>$gpslongitude#,$gpslatitude#,0</coordinates>
#[BODY]        </Point>
#[BODY]      </Placemark>
#[TAIL]    </Folder>
#[TAIL]  </Document>
#[TAIL]</kml>

The above with examples can be download from here

1 komentarz: