Update pages/12_🌲_VertXtractor.py
Browse files- pages/12_🌲_VertXtractor.py +20 -23
pages/12_🌲_VertXtractor.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import folium
|
3 |
-
from streamlit_folium import
|
4 |
from folium.plugins import Draw
|
5 |
import geopandas as gpd
|
6 |
import tempfile
|
@@ -351,40 +351,37 @@ draw = Draw(
|
|
351 |
)
|
352 |
draw.add_to(m)
|
353 |
|
354 |
-
#
|
355 |
-
|
356 |
|
357 |
# Initialize session state for bbox
|
358 |
if 'bbox' not in st.session_state:
|
359 |
-
st.session_state.bbox =
|
360 |
-
|
361 |
-
#
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
max(coord[0] for coord in coords),
|
371 |
-
max(coord[1] for coord in coords)
|
372 |
-
]
|
373 |
|
374 |
# Display and allow editing of bounding box coordinates
|
375 |
st.subheader("Enter Bounding Box Coordinates")
|
376 |
col1, col2, col3, col4 = st.columns(4)
|
377 |
with col1:
|
378 |
-
xmin = st.number_input("Min Longitude", value=st.session_state.bbox[0]
|
379 |
with col2:
|
380 |
-
ymin = st.number_input("Min Latitude", value=st.session_state.bbox[1]
|
381 |
with col3:
|
382 |
-
xmax = st.number_input("Max Longitude", value=st.session_state.bbox[2]
|
383 |
with col4:
|
384 |
-
ymax = st.number_input("Max Latitude", value=st.session_state.bbox[3]
|
385 |
|
386 |
-
if
|
387 |
-
|
388 |
|
389 |
if st.session_state.bbox:
|
390 |
st.write(f"Selected bounding box (WGS84): {st.session_state.bbox}")
|
|
|
1 |
import streamlit as st
|
2 |
import folium
|
3 |
+
from streamlit_folium import st_folium
|
4 |
from folium.plugins import Draw
|
5 |
import geopandas as gpd
|
6 |
import tempfile
|
|
|
351 |
)
|
352 |
draw.add_to(m)
|
353 |
|
354 |
+
# Use st_folium to render the map and get the drawn bbox
|
355 |
+
output = st_folium(m, width=700, height=500)
|
356 |
|
357 |
# Initialize session state for bbox
|
358 |
if 'bbox' not in st.session_state:
|
359 |
+
st.session_state.bbox = [6.0, 46.0, 10.0, 47.0] # Default values for Switzerland
|
360 |
+
|
361 |
+
# Update bbox if a new one is drawn
|
362 |
+
if output['last_active_drawing']:
|
363 |
+
coordinates = output['last_active_drawing']['geometry']['coordinates'][0]
|
364 |
+
st.session_state.bbox = [
|
365 |
+
min(coord[0] for coord in coordinates),
|
366 |
+
min(coord[1] for coord in coordinates),
|
367 |
+
max(coord[0] for coord in coordinates),
|
368 |
+
max(coord[1] for coord in coordinates)
|
369 |
+
]
|
|
|
|
|
|
|
370 |
|
371 |
# Display and allow editing of bounding box coordinates
|
372 |
st.subheader("Enter Bounding Box Coordinates")
|
373 |
col1, col2, col3, col4 = st.columns(4)
|
374 |
with col1:
|
375 |
+
xmin = st.number_input("Min Longitude", value=st.session_state.bbox[0], format="%.4f", key="xmin")
|
376 |
with col2:
|
377 |
+
ymin = st.number_input("Min Latitude", value=st.session_state.bbox[1], format="%.4f", key="ymin")
|
378 |
with col3:
|
379 |
+
xmax = st.number_input("Max Longitude", value=st.session_state.bbox[2], format="%.4f", key="xmax")
|
380 |
with col4:
|
381 |
+
ymax = st.number_input("Max Latitude", value=st.session_state.bbox[3], format="%.4f", key="ymax")
|
382 |
|
383 |
+
# Update session state if coordinates are manually changed
|
384 |
+
st.session_state.bbox = [xmin, ymin, xmax, ymax]
|
385 |
|
386 |
if st.session_state.bbox:
|
387 |
st.write(f"Selected bounding box (WGS84): {st.session_state.bbox}")
|