How to find geolocation of a photo in Linux?

exiftool can be used to print out the metadata of the image. If the location was stored when the image was taken (usually called 'geotagging'), you can find it there:

$ exiftool 23.jpg  | grep GPS
GPS Latitude Ref                : North
GPS Longitude Ref               : East
GPS Latitude                    : 35 deg 32' 16.80" N
GPS Longitude                   : 139 deg 29' 49.20" E
GPS Position                    : 35 deg 32' 16.80" N, 139 deg 29' 49.20" E
$

You can also use exiftool to strip the GPS information out of an existing image:

$ exiftool -gps:all= 23.jpg
    1 image files updated
$ exiftool 23.jpg | grep GPS
$

Any tool that can look at image metadata can look at this information. For example, the identify tool from ImageMagic will also do it:

$ identify -verbose 23.jpg | grep GPS
    exif:GPSInfo: 640
    exif:GPSLatitude: 35/1, 3228/100, 0/1
    exif:GPSLatitudeRef: N
    exif:GPSLongitude: 139/1, 2982/100, 0/1
    exif:GPSLongitudeRef: E
$

and GUI tools can often do so as well - here's Image Viewer from Ubuntu 18:

Image Viewer Details/Metadata

Many images do not have GPS entries in their metadata - for example, if you take a picture with a camera that doesn't have GPS, it won't store it - here's a list of cameras that do have GPS.

Most cell phones, of course, have a GPS, and often will geotag by default. You can choose to disable this in Android and iPhones.


This command will check your photos in a directory and looks up whether Geo tags are saved in Exif. It will report those where data was found:

for f in *.jpg; do CMD="$(exiftool -a -gps:all "$f" 2>/dev/null | grep "GPS Latitude")"; RET=$?; if [ "$RET" -eq "0" ]; then echo "$f"; fi; done

If you want to automatically parse the geo information in computer-readable format in order to further process the coordinates, you can use this

exiftool -c "%+.6f" "$1" |grep "GPS Position" | cut -d":" -f2 | tr -d ' '

This tool (bash script) does it automatically on the file that is passed to it as argument: https://gist.github.com/pas-calc/0e6063affa749fedc2e51cea88345929 . The results will be displayed on the Geo Tool website.