Embedding geotags in digital photos
X Marks the Spot
Add location data to your best digital images with digiKam and GPS Correlate.
Many image formats let you store the GPS coordinates for the image location as metadata. Storing location data with the image makes it easy to document where the image was taken. Some mapping tools will even let you plot the geotagged images on a map; you can click an icon on the map and see what the view was like from that location.
Most smartphones, which typically have built-in GPS capabilities, automatically add location data to captured images. But conventional digital cameras, even many premium cameras, don't have a way to sense and record GPS data.
The good news for users of these cameras is that Linux has some tools that will let you add location data to digital images after the pictures are taken. Most of these tools work with a GPX track. A GPX track is a log of coordinates from a recent hike or road trip. Turn on GPS tracking on your smartphone or GPS device, then start walking or riding. The device will record the data as a track that you can then display using a mapping tool.
This article describes a pair of tools for geotagging digital images: digiKam and GPS Correlate.
Converting Your Track
For many years, most GPS devices supported GPX format out of the box; however, some recent devices now use other formats. For instance, today's Garmin devices use the FIT (Flexible and Interoperable Data Transfer) format, which you will need to convert to GPX to use it with the geotagging tools described in this article. You can use a tool called GPSBabel [1] to convert virtually any track format.
The GPSBabel program supports almost all relevant formats and lets you convert relatively easily. To convert, for example, a FIT file, use the garmin_fit
option as a parameter for the GPSBabel program (Listing 1).
Listing 1
Converting a FIT
If you favor a GUI, the GPSBabel tool does have a graphical interface named Gebabbel, but my impression is that Gebabbel doesn't really make using GPSBabel much easier, because it also ultimately requires input at the command line.
Once you have the GPX tracks for the tour, you can start tagging. The coordinates of each track must exist in its own file. You can collect all your tracks in a directory and specify all the files to correlate. The programs ignore tracks that you recorded on days other than the days the images were processed.
digiKam
If you already use the open source digiKam photo tool [2] to manage images, you might already be familiar with a feature called Edit Coordinates, or something similar – the name has changed several times in recent versions. You will find it under Image | Geolocation | Edit Coordinates.
When you select Edit Coordinates, digiKam displays a wizard to let you associate your photos with locations on the GPX track. You can either position the images on the map with your mouse to associate the image with the corresponding coordinates, or you can use using the GPS Correlator tab on the right margin (Figure 1).
If you load multiple GPS tracks at the same time, digiKam shows them in different colors to distinguish between tracks.
The Manual option and Fine offset (mm:ss) below Camera time zone help you synchronize the clocks in the camera and your GPS device (Figure 2). Interpolate tells the application to calculate any missing timestamps automatically. The synchronization feature could cause problems if you connect multiple tracks over a period of time: synchronization is only intended to plug minor gaps in the tracks, such as when woods or buildings prevented reception.
Pressing Correlate accepts the data in the images. To check whether the correlation was successful, check randomly selected images to see whether they were positioned correctly on the map. If you have defined an offset, check that the sign is correct. If you receive an error message, look for non-correlated images.
The easiest way of doing this is to open the images as a list and then sort them by latitude. Images that the application did not map are at the top of the list. Try to find out why they were not matched: Missing a track? Faulty Exif data? If you want to position the images manually, now is the right time to do it.
You can stop the action by pressing the Apply button, which tells the program to write the data to the images. If you want to write data to RAW files, you will need to enable the option for writing metadata in the digiKam configuration. Choose the Settings menu below Configure digiKam, select the Metadata tab, and enable the option labeled If possible, write metadata to raw files (experimental). Alternatively, you could add the metadata to XMP sidecar files.
GPS Correlate
Another option for geotagging digital images is GPS Correlate [3]. GPS Correlate consists of two components: a program for the command line (gpscorrelate
) and a GUI (Figure 3). Like digiKam, GPS Correlate can work with RAW files as well as JPEGs.
The GPS Correlate interface is simpler than digiKam's wizard. The tool displays the data very clearly, which really helps if you have to manage many images. However, some stumbling blocks spoil the overall good impression: If the timestamps were not recorded precisely, the software is significantly less capable of automatically correlating images than the digiKam wizard. Also, the software does not let you automatically sort the non-mapped images so that entries appear within a block in the list. Finally, a preview feature, which is always useful for troubleshooting, is missing.
You manage the command-line variant through a series of options. Table 1 summarizes the most important. By default, the tool changes the image files it processes, even RAW files, without providing feedback. The Don't write option in the GUI and command-line parameter n
prevent this automatic write option.
Table 1
GPS Correlate Options
Option | Function |
---|---|
-g <datafile> |
Specify GPX track used |
-z <+/-HH[:MM]> |
Time offset |
-i |
Disable (linear) interpolation |
-n |
Stop writing to the file |
-m <seconds> |
Maximum time for points outside of the tracks |
-s |
Show stored geographic information from the files |
-o |
Output in machine-readable format |
-r |
Remove geo-information from files |
-t |
Interpolate between the track segments |
-M |
Do not change modification time of file on writing |
-f |
Repair broken time stamps |
-O <seconds> |
Offset time for images |
-v, --verbose |
Output more detail in messages |
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.