app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from geopy.geocoders import Nominatim from geopy.exc import GeocoderServiceError geolocator = Nominatim(user_agent="my_geopy_app") Latitude = "25.594095" Longitude = "85.137566" try: location = geolocator.reverse(Latitude + "," + Longitude) address = location.raw['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) except GeocoderServiceError as e: print("Error: ", e) |