Spaces:
Runtime error
Runtime error
Jonathan Marokhovsky
commited on
Commit
•
0bd11ce
1
Parent(s):
91cb88f
Adding some initual code to try to use streamlit_folium
Browse files
app.py
CHANGED
@@ -83,8 +83,13 @@ with st.sidebar:
|
|
83 |
code = st.text_area(label="code:", value=code_ex, height=400)
|
84 |
|
85 |
# Here we actually compute the total carbon in the requested polygon
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
88 |
x = (
|
89 |
rioxarray.open_rasterio("/vsicurl/" + deforest, masked=True)
|
90 |
.rio.clip(geo.geometry.values, geo.crs, from_disk=True)
|
@@ -99,7 +104,11 @@ st.divider()
|
|
99 |
|
100 |
# run whatever python code is in the python box, just for fun
|
101 |
eval(compile(code, "<string>", "exec"))
|
102 |
-
m.to_streamlit(height=700)
|
|
|
|
|
|
|
|
|
103 |
|
104 |
"## Explore Further"
|
105 |
st.write("""
|
|
|
83 |
code = st.text_area(label="code:", value=code_ex, height=400)
|
84 |
|
85 |
# Here we actually compute the total carbon in the requested polygon
|
86 |
+
# NOTE: It is not possible to access user_roi_bounds from streamlit per: https://github.com/opengeos/leafmap/discussions/152#discussioncomment-1870416
|
87 |
+
# bounds = m.user_roi_bounds()
|
88 |
+
# if bounds is not None:
|
89 |
+
# bounds.set_crs("epsg:4326")
|
90 |
+
|
91 |
+
geo = gpd.read_file(polygon, driver="GeoJSON")
|
92 |
+
geo.set_crs("epsg:4326")
|
93 |
x = (
|
94 |
rioxarray.open_rasterio("/vsicurl/" + deforest, masked=True)
|
95 |
.rio.clip(geo.geometry.values, geo.crs, from_disk=True)
|
|
|
104 |
|
105 |
# run whatever python code is in the python box, just for fun
|
106 |
eval(compile(code, "<string>", "exec"))
|
107 |
+
st_data = m.to_streamlit(height=700)
|
108 |
+
polygon = st_data["last_active_drawing"]
|
109 |
+
if polygon is not None:
|
110 |
+
"### The Polygon is: "
|
111 |
+
st.write(f"{polygon}")
|
112 |
|
113 |
"## Explore Further"
|
114 |
st.write("""
|