Show Geotagged Photos on OpenStreetMap

Want to show on the map the place where you took a specific photo? Provided that the photo is geotagged, the simple function below will do the job:

if [ -x "$(command -v exiftool)" ] ; then
function show-on-osm(){
lat=`exiftool -n -p '$GPSlatitude' $1`
lon=`exiftool -n -p '$GPSlongitude' $1`
osm="http://www.openstreetmap.org/?mlat=$lat&mlon=$lon&zoom=18"
xdg-open $osm
}
fi

The function extracts latitude and longitude values from the photo’s EXIF metadata, creates an OpenStreetMap URL, and opens it in the default browser.

For the function to work, you need to install the ExifTool on your system. Add the function to the ~/.bashrc file, and use the show-on-osm foo.JPG command to show the photo you want on OpenStreetMap (replace foo.JPG with the actual name of the desired photo).

This is an excerpt from the Linux Photography book. Get your copy here.

Tech writer covering Linux and open source software

Posted in Open Source, Photography, Software
2 comments on “Show Geotagged Photos on OpenStreetMap
  1. Stefan says:

    Thanks for sharing this script. Would it be easy to modify it in order to display a map with several places using a command such as ‘show-on-osm foo1.jpg foo2.jpg foo3.jpg” or ‘show-on-osm *.jpg’?

Comments are closed.

%d bloggers like this: