Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import folium
|
| 4 |
+
|
| 5 |
+
# Load data
|
| 6 |
+
data = {
|
| 7 |
+
'Name': ['Location_A', 'Location_B', 'Location_C', 'Location_D', 'Location_E'],
|
| 8 |
+
'latitude': np.random.uniform(40.7, 40.8, size=5), # Assuming latitude range between 40.7 and 40.8
|
| 9 |
+
'longitude': np.random.uniform(-74.0, -73.9, size=5) # Assuming longitude range between -74.0 and -73.9
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
# Create DataFrame
|
| 13 |
+
df = pd.DataFrame(data)
|
| 14 |
+
|
| 15 |
+
# Sidebar for user input
|
| 16 |
+
st.sidebar.title('Filters')
|
| 17 |
+
selected_column = st.sidebar.selectbox('Select Column', data.columns)
|
| 18 |
+
|
| 19 |
+
# Filter data based on user selection
|
| 20 |
+
filtered_data = data[selected_column]
|
| 21 |
+
|
| 22 |
+
# Display the filtered data
|
| 23 |
+
st.write('Filtered Data:')
|
| 24 |
+
st.write(filtered_data)
|
| 25 |
+
|
| 26 |
+
# Create a map object
|
| 27 |
+
m = folium.Map(location=[filtered_data['latitude'].mean(), filtered_data['longitude'].mean()], zoom_start=10)
|
| 28 |
+
|
| 29 |
+
# Add markers to the map
|
| 30 |
+
for index, row in filtered_data.iterrows():
|
| 31 |
+
folium.Marker([row['latitude'], row['longitude']], popup=row['popup_text']).add_to(m)
|
| 32 |
+
|
| 33 |
+
# Render the map
|
| 34 |
+
folium_static(m)
|