News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Extract GPS coordinates for all pictures in one file

Started by angelpoo, January 20, 2011, 07:15:12 PM

Previous topic - Next topic

angelpoo

Aloha,

I am looking for a command line that does the following:
Extracts only the GPS lat/long information from all photos in a directory and puts them all in one text file.
Essentially, the txt will have three columns:  The first is the photo name and the second and third will be the lat long.

Can this be done?  I have tried some combinations but failed.  Now I am totally confused.

Thanks in advance for the help!

Chui

Phil Harvey

Hi Chui,

Try this command:

exiftool -filename -gpslatitude -gpslongitude -T DIR > out.txt

where DIR is the name of a directory containing the images (like c:\pictures for example).  Put quotes around the directory name if it contains spaces.

This command will create a tab-delimited file called "out.txt" with your specified columns.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

angelpoo

Wow!  Thanks Phil!  It worked perfect! 

Is there a way to change those output lat/long into decimal degrees?  And if so, will the conversion cause a loss of precision in the coordinates?

Chui

Phil Harvey

Hi Chui,

Add the -n option to the command to output the coordinates as signed decimal degrees.   In fact, you may gain precision by doing this because the -n value is returned at the full precision available.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

angelpoo

Thanks Phil for all your help.  I know you hear this often but Exiftool is awesome!  ;D

Phil Harvey

Hi Chui,

Quote from: angelpoo on January 21, 2011, 12:50:21 PM
I know you hear this often but Exiftool is awesome!  ;D

I may have heard it before, but I don't often acknowledge because I'm not very good at accepting praise.  However, it is appreciated.  Thanks. :)
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

PIBO

This also worked great for me! Thanks Phil.

I do have an additional question:

I have a directory/folder that contains a whole bunch of other directories/folders with geotagged photos in them. I'm looking for a quick way, batch style, to have exiftool look through all of the folders and all of the photos within, extract coordinates, and put them in the text file. Is this possible? Could it also label the photos based on which folder they came out of?

Thanks in advance.

Phil Harvey

Sure.  The -r option recurses into sub-directories, and just add -directory to output the directory name:

exiftool -filename -directory -gpslatitude -gpslongitude -T -r DIR > out.txt

Or, you could use the new -csv option, which automatically writes out a "SourceFile" column which is the full path name of the file:

exiftool -gpslatitude -gpslongitude -csv -r DIR > out.csv

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

PIBO

Wow! Always such fast and clear responses. Thanks so much.

BenjaminTheThird

Hi Phil,
I'm having troubles with the command to extract the GPS data. It doesn't write the .txt file. Any ideas?

Hayo Baan

What system are you running on, and what is the exact command you used?
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

If you used the command in my first post of this thread, it will have created an "out.txt" file in the current directory from where you ran exiftool.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

BenjaminTheThird

Thank you both for your responses. Yes it's there alright...up a couple of directories. I kept expecting to see it in the same directory as the photos (my programmer Neighbour helped me straight away). Apologies if I wasted your time. I can see I'm going to be having fun with ExifTool...I've been able to create a photo (Google) map of over 100 images of road defects (on proof sheets). I've got 1000's more to do - so your tool is awesome for the job [just importing a photo library into Google Maps muddled up the sequence for some reason]. I just donated $10AUD. Much obliged, Ben.  :)

Phil Harvey

Hi Ben,

Glad you got it working.

Thanks for the donation!

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pgogborn

This thread gave me a quick solution to what I wanted to do in particular and gave me a toehold into understanding/using the power of ExifTool.

Thank you Phil Harvey.