Created
March 26, 2013 01:48
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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