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
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.