Skip to content

Instantly share code, notes, and snippets.

@cporter
Created March 26, 2013 01:48
Show Gist options
  • Save cporter/5242456 to your computer and use it in GitHub Desktop.
Save cporter/5242456 to your computer and use it in GitHub Desktop.
A simple script demonstrating the geopy API. You can install geopy via "sudo easy_install geopy". Expected input is one address per line on stdin. Output is, tab-delimited, LAT LON PLACE.
import geopy, sys
def main():
g = geopy.geocoders.GoogleV3()
for line in sys.stdin:
addr = line.strip()
try:
place, (lat, lon) = g.geocode(addr)
print '%f\t%f\t%s' % (lat, lon, place)
except:
print 'NaN\tNaN\tNo results for "%s"' % addr
if '__main__' == __name__:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment