Open MDKempe opened 1 month ago
When not doing a geospatial analysis get the city, state, country, prefecture, county, or other meta data fields filled in.
(https://www.geeksforgeeks.org/get-the-city-state-and-country-names-from-latitude-and-longitude-using-python/)
pip install geopy
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="geoapiExercises")
Latitude = "25.594095" Longitude = "85.137566"
location = geolocator.reverse(Latitude+","+Longitude)
print(location)
address = location.raw['address'] print(address)
city = address.get('city', '') state = address.get('state', '') country = address.get('country', '') code = address.get('country_code') zipcode = address.get('postcode') print('City : ',city) print('State : ',state) print('Country : ',country) print('Zip Code : ', zipcode)
This should be implemented as a separate function so that it can be more flexibly used outside of the PSM meteorological data call.
When not doing a geospatial analysis get the city, state, country, prefecture, county, or other meta data fields filled in.
(https://www.geeksforgeeks.org/get-the-city-state-and-country-names-from-latitude-and-longitude-using-python/)
pip install geopy
import module
from geopy.geocoders import Nominatim
initialize Nominatim API
geolocator = Nominatim(user_agent="geoapiExercises")
Latitude & Longitude input
Latitude = "25.594095" Longitude = "85.137566"
location = geolocator.reverse(Latitude+","+Longitude)
Display
print(location)
address = location.raw['address'] print(address)
city = address.get('city', '') state = address.get('state', '') country = address.get('country', '') code = address.get('country_code') zipcode = address.get('postcode') print('City : ',city) print('State : ',state) print('Country : ',country) print('Zip Code : ', zipcode)