NREL / PVDegradationTools

Set of tools to calculate degradation responses and degradation related parameters for PV.
https://pvdegradationtools.readthedocs.io/
Other
23 stars 5 forks source link

Get City State and Country in PSM data #92

Open MDKempe opened 1 month ago

MDKempe commented 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

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 commented 1 month ago

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