from geopy.geocoders import Nominatim | |
import gradio as gr | |
def get_location(address): | |
try: | |
# calling the Nominatim tool | |
loc = Nominatim(user_agent="GetLoc") | |
# entering the location name | |
getLoc = loc.geocode(address) | |
# latitude and longitude | |
lat = getLoc.latitude | |
lon = getLoc.longitude | |
#display location processing | |
value = "Latitude = " + str(lat) + "\n" + "Longitude = " + str(lon) | |
identified_location= gr.Textbox(visible=True, interactive=False, | |
label="Identified GPS Location", | |
value=value) | |
return identified_location | |
except: | |
error = "Please try another less precise location." | |
identified_location= gr.Textbox(visible=True, interactive=False, | |
label="Identified GPS Location", | |
value=error) | |
return identified_location |