Update app.py
Browse files
app.py
CHANGED
@@ -5,22 +5,20 @@ import plotly.express as px
|
|
5 |
from datasets import load_dataset
|
6 |
import folium
|
7 |
from streamlit_folium import st_folium
|
8 |
-
|
9 |
-
from geopy.exc import GeopyError
|
10 |
-
import subprocess
|
11 |
-
import sys
|
12 |
|
13 |
-
#
|
14 |
-
def
|
15 |
try:
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
# Hugging Face Datasets
|
26 |
@st.cache_data
|
@@ -77,14 +75,6 @@ def generate_terrain_data():
|
|
77 |
|
78 |
terrain_data = generate_terrain_data()
|
79 |
|
80 |
-
# Reverse Geocoding Function
|
81 |
-
def get_location_name(lat, lon):
|
82 |
-
try:
|
83 |
-
location = geolocator.reverse((lat, lon), exactly_one=True)
|
84 |
-
return location.address if location else "Unknown Location"
|
85 |
-
except GeopyError:
|
86 |
-
return "Error: Unable to fetch location"
|
87 |
-
|
88 |
# Add Location Name to Filtered Data
|
89 |
if include_human_readable:
|
90 |
filtered_data = terrain_data[
|
|
|
5 |
from datasets import load_dataset
|
6 |
import folium
|
7 |
from streamlit_folium import st_folium
|
8 |
+
import requests
|
|
|
|
|
|
|
9 |
|
10 |
+
# Function to fetch location name using OpenStreetMap Nominatim API
|
11 |
+
def get_location_name(lat, lon):
|
12 |
try:
|
13 |
+
url = f"https://nominatim.openstreetmap.org/reverse?format=json&lat={lat}&lon={lon}&zoom=10&addressdetails=1"
|
14 |
+
response = requests.get(url)
|
15 |
+
if response.status_code == 200:
|
16 |
+
data = response.json()
|
17 |
+
return data.get("display_name", "Unknown Location")
|
18 |
+
else:
|
19 |
+
return "Error: Unable to fetch location"
|
20 |
+
except Exception as e:
|
21 |
+
return f"Error: {str(e)}"
|
22 |
|
23 |
# Hugging Face Datasets
|
24 |
@st.cache_data
|
|
|
75 |
|
76 |
terrain_data = generate_terrain_data()
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
# Add Location Name to Filtered Data
|
79 |
if include_human_readable:
|
80 |
filtered_data = terrain_data[
|