table of contents
GPSCORRELATE(1) | gpscorrelate 2.3 | GPSCORRELATE(1) |
NAME¶
gpscorrelate - correlates digital images with GPS data filling EXIF fields
SYNOPSIS¶
gpscorrelate [{-g file.gpx} | {[-l | --latlong latitude,longitude[,elevation] ]}] [-z | --timeadd +/-HH[:MM]] [--no-photo-tz] [-O | --photooffset seconds] [-i | --no-interpolation] [-v | --verbose] [-d | --datum datum] [-n | --no-write] [-R | --replace] [-m | --max-dist time] [-t | --ignore-tracksegs] [--heading] [-B | --max-heading degrees] [-b | --direction degrees] [-M | --no-mtime] [--degmins] image.jpg...
gpscorrelate {-s | --show | -o | --machine} image.jpg...
gpscorrelate {-x | --show-gpx} [-z | --timeadd +/-HH[:MM]] [--no-photo-tz] [-O | --photooffset seconds] image.jpg...
gpscorrelate {-r | --remove} [-M | --no-mtime] image.jpg...
gpscorrelate {-f | --fix-datestamps} {-z | --timeadd +/-HH[:MM]} image.jpg...
gpscorrelate -V | --version | -h | --help
DESCRIPTION¶
This manual page documents the gpscorrelate command. There is extended documentation available in HTML format; see below.
gpscorrelate is a program that acts on digital images in JPEG format, filling in the EXIF (Exchangeable Image File Format) fields related to GPS (Global Positioning System) information. Source for the GPS data is a GPX (GPS Exchange Format) file, which records GPS location information in an XML-based format. The act of filling those fields is referred to as correlation.
If GPS data are available at the precise moment the image was taken (with a 1-second granularity) the GPS data are stored unmodified in EXIF fields. If they are not, linear interpolation of GPS data available at moments before and after the image was taken can be used. If the image contains sub-second time resolution, it is used to obtain a more accurate estimate of the position between the two points. Linear interpolation gives good results when points are close together, but if they are several kilometres apart (such as on an infrequently-sampled airplane track), it will introduce some error versus the great circle route an airplane normally flies. A measure of the approximate accuracy of the GPS location reading (based on the number of digits recorded in the track point) is preserved when written into the image through the denominator of rational value fields. A GPSDOP tag is also written for exact point matches when satellite HDOP information is available, providing a more dependable estimate of location accuracy.
The interpolation algorithm assumes that time values in GPX files are strictly increasing, which is normally the case. If a GPX file is found to violate this assumption, the message Warning: track points are not ordered by time is written so stderr along with the first backwards-going time value. Any location values written to images using such a file may not be using the best GPS coordinate points available if the images were taken around the time of the time incongruity. No warning is given if time between track segments goes backwards, which would only affect correlations when --ignore-tracksegs is used. The --max-dist option can be used to place a limit on how large a time gap is accepted, which can limit the effect if this occurs.
OPTIONS¶
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below.
-g, --gps file.gpx
-l, --latlong latitude,longitude[,elevation]
Note that this option has a known limitation in that it does not honour the locale's decimal place character in locales that use other than ".".
-s, --show
-x, --show-gpx
-o, --machine
-r, --remove
-z, --timeadd +/-HH[:MM]
--no-photo-tz
-O, --photooffset seconds
-i, --no-interpolation
-v, --verbose
-d, --datum datum
-n, --no-write
-R, --replace
-m, --max-dist time
If a clear view of sufficient GPS satellites is lost while recording a track, then there may be location gaps in the GPX file. If the accuracy of the recorded location is paramount and you would rather not correlate a position at all for a photo if the available GPS coordinates were recorded too long ago in the past or too far into the future (relative to when the photo was taken), then set this to a nonzero value.
This option will also prevent recording heading and direction under the same circumstances (see --max-heading for a discussion of when this may be needed).
-t, --ignore-tracksegs
--heading
gpscorrelate treats each of these tags as holding the true direction of movement, but they aren't very well defined and might not hold exactly what's expected. For example, a phone might store the direction it's facing rather than the direction of movement, or the direction might be the magnetic heading instead of true heading. Or, a device might estimate the heading from GPS movement which will be inaccurate at slow speeds. Use your knowledge of the recording application to determine how much faith you can place in the resulting tags.
If this is used with --latlong instead of with --gps, then a fixed heading of 0 is written (this is subject to change in the future).
-B, --max-heading degrees
This option won't prevent writing an incorrect heading or direction in the case where GPS points are sparser than the time it takes the recording vehicle to make a nearly 360° turn. For example, if the vehicle takes 8 seconds to turn completely around but GPS tags are written every 10 seconds, then the two points written at either end of the turn could have headings that are very close (within --max-heading) yet a picture taken in the middle of the turn, 4 seconds after the first tag, would have an interpolated heading that is around 180° off the correct value. Prevent this kind of bad value from being written by setting a --max-dist that is much less than the time it takes to turn around, such as 4 in this example.
-b, --direction degrees
This may be used with --latlong in which case the argument is used as the camera direction without alteration.
-M, --no-mtime
-f, --fix-datestamps
--degmins
-h, --help
-V, --version
EXAMPLES¶
Correlate all photos in a directory taken in western Europe in the summer (i.e., UTC-2):
gpscorrelate -g Test.gpx -z 2 *.jpg
Correlate all photos in a directory taken in Italy, switching to UTC-2 or UTC-1 depending on the daylight savings time in effect when the first picture in the list was taken:
env TZ=Europe/Rome gpscorrelate -g Test.gpx *.jpg
Correlate all photos in a directory from a track spread out over two different track files and taken in the computer's current time zone, interpolating between segments and between files while ignoring photos taken too far away from a recorded point, without changing the file time stamp of the files, while showing details of the process:
gpscorrelate -g track1.gpx -g track2.gpx -m 120 -t -M -v *.jpg
Correlate images taken from a dashcam, adding direction tags from the GPX file:
gpscorrelate --heading --max-heading 90 --direction 0 -g Test.gpx *.jpg
Correlate a set of photos taken with a camera aimed straight out of the right-hand passenger side window of a car (90° from straight ahead), using a GPX file containing direction tags, skipping direction tagging during fast turns and all tags when a GPS lock is lost for more than 6 seconds (to avoid writing inaccurate tags):
gpscorrelate -g car_trip.gpx --heading --max-heading 45 --direction 90 --max-dist 6 --ignore-tracksegs *.jpg
Correlate a photo taken from a camera with a fast clock (i.e., the clock was 77.5 seconds ahead of GPS time) and with incorrectly-specified time zone tags:
gpscorrelate -g Test.gpx -O -77.5 --no-photo-tz photo.jpg
Show existing GPS tags in a photo:
gpscorrelate --show photo.jpg
Show existing GPS tags in a photo and output in CSV format:
gpscorrelate --show --machine photo.jpg
Create a GPX track from a set of images taken in the UK in winter that are already GPS tagged (e.g., as might come from a cell phone camera), which can be used to correlate other photos taken on another nearby camera:
gpscorrelate --show-gpx -z 0 IMG*.JPG
Remove GPS tags from photos:
gpscorrelate --remove *.jpg
Add a GPS location tag to a photo taken to the southeast at Ulmer Münster:
gpscorrelate -l 48.398620,9.991417,522 --direction 135 -z 2 ulm.jpg
EXIT STATUS¶
gpscorrelate returns 0 in case of success, 1 in case of major error (such as a read or write error) and 2 in case of minor error (such as the given GPS track not covering the time of an image).
SEE ALSO¶
gpsd(1), gpsbabel(1), gpxlogger(1), cgpxlogger(1).
The documentation of gpscorrelate in HTML format is available on the filesystem at /usr/share/doc/gpscorrelate.
LICENSE¶
This manual page was initially written by Stefano Zacchiroli <zack@debian.org> for the Debian(TM) system. It was extended by Till Maas <opensource@till.name> and Dan Fandrich <dan@coneharvesters.com>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation.
AUTHOR¶
Stefano Zacchiroli
COPYRIGHT¶
Copyright © 2006-2025 Stefano Zacchiroli <zack@debian.org>, Till Maas, Dan Fandrich
13 Feb 2025 | gpscorrelate 2.3 |