Created
June 29, 2016 18:06
-
-
Save Zsoldier/dccc79e1c232f9d6c78b5b72568cb2de to your computer and use it in GitHub Desktop.
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 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
| #!/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