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
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.