Easy geocoding with Google Maps using python
For a project, I had to resolve street address into geographic coordinates (geocode), here is a minimal piece of code using the Google Maps API Services :
import urllib
import json
def geocode(addr, api_key=''):
url = "http://maps.google.com/maps/geo?q=%s&output=json&api_key=%s" % (urllib.quote(addr), urllib.quote(api_key))
data = urllib.urlopen(url).read()
return json.loads(data)['Placemark'][0]['Point']['coordinates']
data = geocode("1600 Amphitheatre Parkway Mountain View, CA 94043")
print "lat:%s long:%s" % (data[0], data[1])