Geocoding photos based on average coordinates

Started by Ry, August 06, 2023, 06:47:43 AM

Previous topic - Next topic

Ry

Hi all,

I just made a little workflow that uses exiftool for geocoding photos with missing coordinates and sharing here in case it's helpful to anyone. It's about as elegant as a US president but it does the job.

It's useful if you have:
  • A linux system
  • Some geocoded images at the same/similar location as the photos with missing geodata
  • Images organised into rough location subfolders (eg newYork/ london/ madrid/)

For each folder, it will calculate the average coordinates for images with geodata, then write to those without.
  • You can run the first script geopica.sh for each folder to find average location for that folder
  • If desired, you can use the next script geopic.sh to write those coordinates to images that aren't geocoded
  • I kept these separate because some folders may have no images with geocoding, and in this case a configuration file can be set manually in those folders

But if you want to fire everything at once there's a third script that will run the others in for-loops for all folders as long as they're in the same parent directory.

More details and files available at the github repo.

Any feedback would be appreciated - I realise a lot of this is probably ignoring the functionality of exiftool and the code could be reduced significantly!

PH Edit: Fixed links to point to scripts on github.

StarGeek

Not trying to dismiss your hard work, but with exiftool, you can create a geotrack out of the images that have coordinates.  See Inverse Geotagging.  While it's more common to see this operation used to extract a track from a video, it can also be used on a set of images.

Then you can use the regular Geotag command with the newly created geotrack.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Ry

That's really cool thanks for pointing that out. Exiftool continues to amaze!

I couldn't see how inverse geotagging handles multiple input coordinates in this case. Does it also use a mid-point or average?

StarGeek

I don't know all the details, Phil would have to explain exactly what's happening.  But from the top of the Geotagging page
QuoteThe GPS track log file is loaded, and linear interpolation is used to determine the GPS position at the time of the image
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

The interpolation is done to the time of the image between the GPS fixes with the nearest timestamps on either side of the image time.

- 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 ($).