Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get City State and Country in PSM data #92

Open
MDKempe opened this issue May 23, 2024 · 1 comment
Open

Get City State and Country in PSM data #92

MDKempe opened this issue May 23, 2024 · 1 comment

Comments

@MDKempe
Copy link
Collaborator

MDKempe commented May 23, 2024

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)

@MDKempe
Copy link
Collaborator Author

MDKempe commented May 23, 2024

This should be implemented as a separate function so that it can be more flexibly used outside of the PSM meteorological data call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant