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
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.