User:Cyton/reverseGeotagging
To create a gpx track from geotagged images (like the ones taken foir mapillary or kartaview)
see https://exiftool.org/geotag.html#Inverse for the source
Inverse Geotagging
ExifTool also has the ability to create a GPS track file from a series of
geotagged images. The -p
option may be used to output files in
any number of formats. This section gives examples for creating GPX and KML
output files from a set of geotagged images, or from a geotagged video file.
(But note that the -ee
option must be added to the commands below
to extract the full track from a video file.)
<a name="GPX"></a>
Creating a GPX track log
The following print format file may be used to generate a GPX track log from one or more geotagged images:
#------------------------------------------------------------------------------ # File: gpx.fmt # # Description: Example ExifTool print format file to generate a GPX track log # # Usage: exiftool -p gpx.fmt -ee FILE [...] > out.gpx # # Requires: ExifTool version 10.49 or later # # Revisions: 2010/02/05 - P. Harvey created # 2018/01/04 - PH Added IF to be sure position exists # 2018/01/06 - PH Use DateFmt function instead of -d option # 2019/10/24 - PH Preserve sub-seconds in GPSDateTime value # # Notes: 1) Input file(s) must contain GPSLatitude and GPSLongitude. # 2) The -ee option is to extract the full track from video files. # 3) The -fileOrder option may be used to control the order of the # generated track points when processing multiple files. #------------------------------------------------------------------------------ #[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"> #[HEAD]<trk> #[HEAD]<number>1</number> #[HEAD]<trkseg> #[IF] $gpslatitude $gpslongitude #[BODY]<trkpt lat="$gpslatitude#" lon="$gpslongitude#"> #[BODY] <ele>$gpsaltitude#</ele> #[BODY] <time>${gpsdatetime#;my ($ss)=/\.\d+/g;DateFmt("%Y-%m-%dT%H:%M:%SZ");s/Z/${ss}Z/ if $ss}</time> #[BODY]</trkpt> #[TAIL]</trkseg> #[TAIL]</trk> #[TAIL]</gpx>
This example assumes that the GPSLatitude
,
GPSLongitude
, GPSAltitude
and GPSDateTime
tags are all available in each processed FILE. Warnings will be
generated for missing tags. The output GPX format will invalid if any
GPSLatitude
or GPSLongitude
tags are missing, but will
be OK for missing GPSAltitude
or GPSDateTime
tags.
Note that the order of track points in the output GPX file will be the same
as the order of processing the input files, which may not be chronological
depending on how the files are named. The -fileOrder
option may be
used to force processing of files in a particular order. For example, the
following command processes files in order of increasing GPSDateTime
:
exiftool -fileOrder gpsdatetime -p gpx.fmt /Users/Phil/Pictures > out.gpx
Since no directory was specified for gpx.fmt
, this file must
exist in the current directory when the above command is executed. (If the
gpx.fmt
file can't be found then the -p
argument is
interpreted as a string instead of a file name, and the text
"gpx.fmt
" is sent to the output, which isn't what we want.)
The -if
option may be added to ensure that only files containing
GPS information are processed. For example, the following command creates
"out.gpx
" in the current directory from all pictures containing
GPSDateTime
information in directory "pics
" and its
sub-directories:
exiftool -r -if '$gpsdatetime' -fileOrder gpsdatetime -p gpx.fmt pics > out.gpx
Note: In Windows, double quotes ("
) must be used instead of
single quotes ('
) around the -if
argument above.
The "fmt_files" directory of the full exiftool distribution contains this sample format file ("gpx.fmt") as well as a sample which creates GPX waypoints with pictures ("gpx_wpt.fmt").