Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
59fd337
1
Parent(s):
e38d8ed
Update app.py
Browse files
app.py
CHANGED
@@ -10,17 +10,24 @@ import folium
|
|
10 |
from branca.colormap import LinearColormap
|
11 |
|
12 |
# Function to add heatmap layer to folium map
|
13 |
-
def add_heatmap_layer(map_obj,
|
14 |
-
heat_data =
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Function to calculate distance in meters between two coordinates
|
26 |
def calculate_distance(lat1, lon1, lat2, lon2):
|
@@ -252,9 +259,9 @@ with st.container():
|
|
252 |
folium_layermap = folium.Map(location=[custom_lat, custom_lon], zoom_start=zoom_level, control_scale=True)
|
253 |
|
254 |
# Add heatmap layers for 'Valor_Urb', 'Valor_Eqp', and 'RENDA'
|
255 |
-
add_heatmap_layer(folium_layermap, filtered_data, 'Valor_Urb', 'RdBu_r'
|
256 |
-
add_heatmap_layer(folium_layermap, filtered_data, 'Valor_Eqp', 'RdBu_r'
|
257 |
-
add_heatmap_layer(folium_layermap, filtered_data, 'RENDA', 'RdBu_r'
|
258 |
|
259 |
# Add layer control
|
260 |
folium.LayerControl().add_to(folium_layermap)
|
|
|
10 |
from branca.colormap import LinearColormap
|
11 |
|
12 |
# Function to add heatmap layer to folium map
|
13 |
+
def add_heatmap_layer(map_obj, data, column_name, colormap_name, radius=15):
|
14 |
+
heat_data = data[['latitude', 'longitude', column_name]].dropna()
|
15 |
+
heat_layer = folium.FeatureGroup(name=f'Heatmap - {column_name}')
|
16 |
+
|
17 |
+
cmap = LinearColormap(colors=['blue', 'white', 'red'], vmin=heat_data[column_name].min(), vmax=heat_data[column_name].max())
|
18 |
+
|
19 |
+
for index, row in heat_data.iterrows():
|
20 |
+
folium.CircleMarker(
|
21 |
+
location=[row['latitude'], row['longitude']],
|
22 |
+
radius=radius,
|
23 |
+
fill=True,
|
24 |
+
fill_color=cmap(row[column_name]),
|
25 |
+
fill_opacity=0.7,
|
26 |
+
color='black',
|
27 |
+
weight=0.5,
|
28 |
+
).add_to(heat_layer)
|
29 |
+
|
30 |
+
heat_layer.add_to(map_obj)
|
31 |
|
32 |
# Function to calculate distance in meters between two coordinates
|
33 |
def calculate_distance(lat1, lon1, lat2, lon2):
|
|
|
259 |
folium_layermap = folium.Map(location=[custom_lat, custom_lon], zoom_start=zoom_level, control_scale=True)
|
260 |
|
261 |
# Add heatmap layers for 'Valor_Urb', 'Valor_Eqp', and 'RENDA'
|
262 |
+
add_heatmap_layer(folium_layermap, filtered_data, 'Valor_Urb', 'RdBu_r')
|
263 |
+
add_heatmap_layer(folium_layermap, filtered_data, 'Valor_Eqp', 'RdBu_r')
|
264 |
+
add_heatmap_layer(folium_layermap, filtered_data, 'RENDA', 'RdBu_r')
|
265 |
|
266 |
# Add layer control
|
267 |
folium.LayerControl().add_to(folium_layermap)
|