Created
June 29, 2016 18:06
Star
You must be signed in to star a gist
Simple Python script that returns city name from provided longitude and latitude variables from bash. Uses geopy module and appears to work both on Python 2 and 3. City return may or may not be accurate. Kind of guessing by selecting 3rd return record from google and selecting first entry in comma separated return. Needs work obviously.
This file contains 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
#!/usr/bin/python | |
import sys | |
def cityinfo(lat, lon): | |
from geopy.geocoders import GoogleV3 | |
locator = GoogleV3() | |
address = locator.reverse([lat, lon]) | |
city = address[3].address.split(",")[0] | |
print(city.replace(" ", "")) | |
return | |
cityinfo(sys.argv[1], sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment