Script: Extract the Numerical GPS Values Using an Apple Script
Photos for Mac will display photos on a map, if the photos have been tagged with GPS data, but it does not show the numerical values for the GPS coordinates.
This little script will display latitude, longitude, altitude for the currently selected photo in a panel and copy the coordinates to the clipboard. It has been tested on on Photo 4.0 on macOS 10.14.2.
If nothing happens, the panel with the displayed coordinates may be hidden by another window. Then drag the windows around, to find the occluded window, so you can dismiss it.
On older versions of Photos (Photos 2.0 or older) it works best, when the photo has been selected in the "All Photos" album. Other albums and views may produce errors.
-- copy from here -- snip snip
-- This script will display the GPS values and the altitude
-- for a selected photo in a dialog panel.
-- The coordinates will be copied to the clipboard
on ensure_val(the_value, default_value)
-- if the_value is defined return the value,
-- otherwise the default value
if the_value is equal to "missing value" then
return default_value
else
return the_value
end if
end ensure_val
tell application "Photos"
activate
set imageSel to (get selection) -- get the selected image
if imageSel is {} then
error "Please select an image."
end if
tell the first item of imageSel
set loc to get the location
--retrieve longitude and latitude as list
set lati to (the first item of loc) as string
set longi to (the second item of loc) as string
set alti to get the altitude as string -- retrieve the altitude
end tell
end tell
-- check for undefined values
set lati to ensure_val(lati, "latitude empty")
set longi to ensure_val(longi, "longitude empty")
set alti to ensure_val(alti, "altitude empty")
-- display the result in a dialog panel
set panel_message to "Latitude: " & lati & "
Longitude: " & longi & "
Altitude: " & alti & "
Copied to the clipboard"
display dialog panel_message buttons ¬
"OK" with icon caution default button "OK"
-- copy the GPS data to the clipboard
set clipboard_message to " " & lati & " " & longi & " " & alti
set the clipboard to clipboard_message
return clipboard_message
-- copy to here
Old Toad has saved a compiled version of this script for downloading here: http://oldtoad.net/ASC/Extract%20Numerical%20GPS%20Values.zip
This version of the user tip replaces the older version, published on the previous ASC platform.
Script: Extract the Numerical GPS Values … - Apple Community