Author Topic: Extract GPS coordinates for all pictures in one file  (Read 51612 times)

angelpoo

  • Newbie
  • *
  • Posts: 3
Extract GPS coordinates for all pictures in one file
« on: January 20, 2011, 07:15:12 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Extract GPS coordinates for all pictures in one file
« Reply #1 on: January 20, 2011, 07:30:32 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

angelpoo

  • Newbie
  • *
  • Posts: 3
Re: Extract GPS coordinates for all pictures in one file
« Reply #2 on: January 20, 2011, 07:44:57 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Extract GPS coordinates for all pictures in one file
« Reply #3 on: January 20, 2011, 08:43:25 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

angelpoo

  • Newbie
  • *
  • Posts: 3
Re: Extract GPS coordinates for all pictures in one file
« Reply #4 on: January 21, 2011, 12:50:21 PM »
Thanks Phil for all your help.  I know you hear this often but Exiftool is awesome!  ;D

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Extract GPS coordinates for all pictures in one file
« Reply #5 on: January 21, 2011, 01:34:31 PM »
Hi Chui,

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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

PIBO

  • Newbie
  • *
  • Posts: 2
Re: Extract GPS coordinates for all pictures in one file
« Reply #6 on: November 29, 2011, 11:00:16 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Extract GPS coordinates for all pictures in one file
« Reply #7 on: November 29, 2011, 11:39:16 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

PIBO

  • Newbie
  • *
  • Posts: 2
Re: Extract GPS coordinates for all pictures in one file
« Reply #8 on: November 29, 2011, 12:07:09 PM »
Wow! Always such fast and clear responses. Thanks so much.

BenjaminTheThird

  • Newbie
  • *
  • Posts: 2
Re: Extract GPS coordinates for all pictures in one file
« Reply #9 on: March 02, 2017, 10:29:04 PM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1118
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Extract GPS coordinates for all pictures in one file
« Reply #10 on: March 03, 2017, 01:13:21 AM »
What system are you running on, and what is the exact command you used?
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Extract GPS coordinates for all pictures in one file
« Reply #11 on: March 03, 2017, 07:19:05 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

BenjaminTheThird

  • Newbie
  • *
  • Posts: 2
Re: Extract GPS coordinates for all pictures in one file
« Reply #12 on: March 03, 2017, 07:44:16 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Extract GPS coordinates for all pictures in one file
« Reply #13 on: March 03, 2017, 09:06:26 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pgogborn

  • Newbie
  • *
  • Posts: 1
Re: Extract GPS coordinates for all pictures in one file
« Reply #14 on: March 19, 2017, 11:54:31 AM »
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.