Set photo filename to nearby feature with latitude/longitude lookup

Hi all.

I’ve recently returned from a holiday, and like on previous occasions, I download all the photos from my iPhone onto my mac, so that I can name and sort them (my mac holds the master copy of my photos). To help figure out where a photo was taken, I sometimes use the Finder’s Get Info to see the photo latitude/longitude, copy/paste this into the Maps app, and then figure out a name for the file based on what I see in Maps.

It occurred to me that this process could be automated. Ideally, a program or script would, for each file:

  1. Get the latitude/longitude.
  2. Look up the closest feature in maps (hard - to make it work really well, you would need to use different scales, e.g. 50m in a city, but 5km in the country side).
  3. Change the filename to match the feature found in step 2.
  4. Bonus marks - sort photos of the same feature into sub-folders.

I’m not using the Photos app, and I’m not familiar with it, so if there’s some feature there that might help, please let me know.

I’ve searched the forums, and found some references to scripts that put the latitude and longitude into a file name, but what I want is a bit more sophisticated. I guess I might have to use a Google maps API.

I used to write Applescripts (and even made a scriptable application) back in the Classic MacOS days, but my skills are rusty now. The AppleScript dictionary for the Maps app looks pretty generic, so no inspiration there.

If anyone can tell me if this is possible (and if so, suggest an existing script to start with), or suggest an app that does what I want, I would be grateful. Thanks.

I actually don’t think this would take long to cobble together, because Google Maps API will do the hard part for you.

It’s easy to have Applescript grab the latitude and longitude from the metadata, rename a file, and group files into folders by name.

The potentially tricky part - getting the nearest POI from a latitude/longitude - can be handled by Google Maps API.

https://developers.google.com/places/web-service/search

Applescript can just use a “do shell script” to submit a CURL request to the Google Maps API and use ASObjC or JSON Helper or whatever to parse the returned JSON result back into an Applescript record.

Shouldn’t be too bad. I doubt anyone here is going to just write it for you, but if you give it a shot, we’ll probably keep helping you out with any problems you have.

It sounds interesting.

  1. Get the latitude/longitude.
    Easy task. You can get exif data by using Shane’s BridgePlus script library.

–Access to exif data
http://piyocast.com/as/archives/3411

  1. Look up the closest feature in maps
    You have to list up all name and geo-location of land marks.
    I wrote such an AppleScript to find the nearerst rail station (about 8,000).
    Then, calculate the distance between two point and sort them. Get the nearest landmark’s name.

–Calculate the distance between two places
http://piyocast.com/as/archives/951

  1. Change the filename to match the feature found in step 2.
    (Too easy)

  2. Bonus marks - sort photos of the same feature into sub-folders.
    Use Spotlight function by using Shane’s Metadata lib or NSFileManager.

I think this program is not easy but seems very interesting.
I 'd wrote 700 place’s nearest station calculation AppleScript took 2 or 3 days.
At first it took 90 minutes to finish. Now it took about 5 minutes by making several area-zoning functions.

Good Luck!

Model: MacBook Pro 2012
AppleScript: 2.7
Browser: Safari 12.1.2
Operating System: macOS 10.14