
There are some obvious improvements I could make: I could extend the query with more parameters to set the zoom level, force the display to satellite, map, or street view, and so on, but I prefer to stick with the defaults. The Google Maps API automatically drops a marker at the location and centers the map around the marker. The query is then constructed in Line 30, and Line 31 sends it to OS X’s wonderfully useful open command to be opened in the default browser. If there’s a problem in any of those steps, an exception is raised, and Lines 20-21 print an error message and quit.īecause the latitude and longitude are returned in an odd format (a list of three Fractions, one each for degrees, minutes, and seconds), Lines 24-27 are needed to put them in a format we can use to query Google Maps. Lines 9-17 get the name of the file from the command line, open it, and extract the GPS information.
#IPHONE PHOTO GEOTAG GOOGLE HOW TO#
I have a writeup on how to do it via Homebrew if you’re interested. Installing pyexiv2 isn’t the hardest thing in the world, but it takes more than a simple pip pyexiv2.

It uses the standard sys and subprocess libraries and the distinctly non-standard pyexiv2 library. It reads the GPS info from the image file and opens Google Maps in my browser with a marker at the photo’s location.ġ4: latref = md.valueġ5: lat = md.valueġ6: lonref = md.valueġ7: lon = md.valueĢ0: print "No GPS info in file %s" % photoĢ3: # Convert the latitude and longitude to signed floating point values.Ģ4: latitude = float(lat) + float(lat)/60 + float(lat)/3600Ģ5: longitude = float(lon) + float(lon)/60 + float(lon)/3600Ģ6: if latref = 'S': latitude = -latitudeĢ7: if lonref = 'W': longitude = -longitudeĢ9: # Construct the Google Maps query and open it. The new program is called map, and when I call it, map photo.jpg This reads the GPS metadata from the iphone-photo.jpg file and writes it to all the files that start with IMG. The October program is called coordinate, and I use it like this: coordinate -g iphone-photo.jpg IMG* It works well, and I’ve been using it ever since, but once I had a bunch of photos with location info in them, I needed a tool that would do the converse: show me where they were taken. My idea was to be able to take one photo with my iPhone, which would capture the location in its EXIF metadata, and use the script to transfer that information to all the photos I took with my regular camera at that same location.

Next post Previous post Locating your photos on Google Mapsīack in October I wrote a little script that added GPS location information to photos.
