Update pages/5_π_VertXtractor.py
Browse files- pages/5_π_VertXtractor.py +75 -64
pages/5_π_VertXtractor.py
CHANGED
@@ -325,69 +325,80 @@ ortho = st.sidebar.checkbox("Orthophotos", value=True)
|
|
325 |
mnt_resol = st.sidebar.selectbox("MNT Resolution", [0.5, 2.0], index=0)
|
326 |
ortho_resol = st.sidebar.selectbox("Orthophoto Resolution", [0.1, 2.0], index=0)
|
327 |
|
328 |
-
#
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
m = folium.Map(location=[46.8182, 8.2275], zoom_start=8)
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
if
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
363 |
|
364 |
-
|
365 |
-
|
366 |
-
urls = get_urls(bbox_wgs84, mnt, mns, bati3D_v2, bati3D_v3, ortho, mnt_resol, ortho_resol)
|
367 |
-
|
368 |
-
if urls:
|
369 |
-
st.success(f"Found {len(urls)} files to download:")
|
370 |
-
for url in urls:
|
371 |
-
st.write(url)
|
372 |
-
|
373 |
-
# Option to download files
|
374 |
-
if st.button("Download Files"):
|
375 |
-
with st.spinner("Downloading files..."):
|
376 |
-
download_path = download_files(urls, "downloads")
|
377 |
-
st.success(f"Files downloaded to: {download_path}")
|
378 |
-
else:
|
379 |
-
st.warning("No files found for the selected area and options.")
|
380 |
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
mnt_resol = st.sidebar.selectbox("MNT Resolution", [0.5, 2.0], index=0)
|
326 |
ortho_resol = st.sidebar.selectbox("Orthophoto Resolution", [0.1, 2.0], index=0)
|
327 |
|
328 |
+
# Main content area
|
329 |
+
col1, col2 = st.columns([2, 1])
|
330 |
+
|
331 |
+
with col1:
|
332 |
+
st.subheader("Select Area of Interest")
|
333 |
+
m = folium.Map(location=[46.8182, 8.2275], zoom_start=8)
|
334 |
+
draw = Draw(
|
335 |
+
draw_options={
|
336 |
+
'polyline': False,
|
337 |
+
'polygon': False,
|
338 |
+
'circle': False,
|
339 |
+
'marker': False,
|
340 |
+
'circlemarker': False,
|
341 |
+
},
|
342 |
+
edit_options={'edit': False}
|
343 |
+
)
|
344 |
+
draw.add_to(m)
|
345 |
+
folium_static(m)
|
346 |
+
|
347 |
+
with col2:
|
348 |
+
st.subheader("Bounding Box")
|
349 |
+
if 'bbox' not in st.session_state:
|
350 |
+
st.session_state.bbox = None
|
351 |
+
|
352 |
+
if st.button("Get Bounding Box"):
|
353 |
+
draw_data = st.session_state.get("json_data")
|
354 |
+
if draw_data and "features" in draw_data:
|
355 |
+
feature = draw_data["features"][0]
|
356 |
+
if feature["geometry"]["type"] == "rectangle":
|
357 |
+
coords = feature["geometry"]["coordinates"][0]
|
358 |
+
st.session_state.bbox = [
|
359 |
+
min(coord[0] for coord in coords),
|
360 |
+
min(coord[1] for coord in coords),
|
361 |
+
max(coord[0] for coord in coords),
|
362 |
+
max(coord[1] for coord in coords)
|
363 |
+
]
|
364 |
+
|
365 |
+
if st.session_state.bbox:
|
366 |
+
st.write(f"Selected bounding box (WGS84): {st.session_state.bbox}")
|
367 |
|
368 |
+
# Convert bbox to LV95
|
369 |
+
bbox_results = detect_and_convert_bbox(st.session_state.bbox)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
+
if bbox_results:
|
372 |
+
bbox_wgs84, bbox_lv95 = bbox_results
|
373 |
+
st.write(f"Converted bounding box (LV95): {bbox_lv95}")
|
374 |
+
|
375 |
+
if st.button("Get Download Links"):
|
376 |
+
with st.spinner("Fetching download links..."):
|
377 |
+
urls = get_urls(bbox_wgs84, mnt, mns, bati3D_v2, bati3D_v3, ortho, mnt_resol, ortho_resol)
|
378 |
+
|
379 |
+
if urls:
|
380 |
+
st.success(f"Found {len(urls)} files to download:")
|
381 |
+
for url in urls:
|
382 |
+
st.write(url)
|
383 |
+
|
384 |
+
# Option to download files
|
385 |
+
if st.button("Download Files"):
|
386 |
+
with st.spinner("Downloading files..."):
|
387 |
+
download_path = download_files(urls, "downloads")
|
388 |
+
st.success(f"Files downloaded to: {download_path}")
|
389 |
+
else:
|
390 |
+
st.warning("No files found for the selected area and options.")
|
391 |
+
|
392 |
+
# Option to download forest data
|
393 |
+
if st.button("Download Forest Data"):
|
394 |
+
with st.spinner("Downloading forest data..."):
|
395 |
+
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.geojson') as tmp:
|
396 |
+
geojson_forest(bbox_lv95, tmp.name)
|
397 |
+
gdf = gpd.read_file(tmp.name)
|
398 |
+
st.write(gdf)
|
399 |
+
os.unlink(tmp.name)
|
400 |
+
st.success("Forest data downloaded and displayed.")
|
401 |
+
else:
|
402 |
+
st.error("Selected area is outside Switzerland. Please select an area within Switzerland.")
|
403 |
+
|
404 |
+
st.sidebar.info("This application allows you to download various types of geospatial data for Switzerland. Select the data types you want, draw a bounding box on the map, and click 'Get Download Links' to see available files.")
|