Spaces:
Sleeping
Sleeping
fix it
Browse files
app.py
CHANGED
@@ -177,15 +177,24 @@ m.add_gdf(
|
|
177 |
zoom_to_layer=True,
|
178 |
style_function=lambda x: {"color": "red", "fillOpacity": 0.0},
|
179 |
)
|
180 |
-
m.to_streamlit(height=height)
|
181 |
|
182 |
# Metrics
|
183 |
-
stats_df = pd.DataFrame()
|
184 |
stats_df["Points"] = str(json.loads(geometry_gdf.to_crs(4326).to_json())["features"][0]["geometry"]["coordinates"])
|
185 |
stats_df["Centroid"] = geometry_gdf.centroid.to_crs(4326).item()
|
186 |
stats_df["Area (ha)"] = geometry_gdf.geometry.area.item() / 10000
|
187 |
stats_df["Perimeter (m)"] = geometry_gdf.geometry.length.item()
|
|
|
|
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
st.write("<h3><div style='text-align: center;'>Geometry Metrics</div></h3>", unsafe_allow_html=True)
|
190 |
# st.markdown(
|
191 |
# f"""| Metric | Value |
|
@@ -193,8 +202,7 @@ st.write("<h3><div style='text-align: center;'>Geometry Metrics</div></h3>", uns
|
|
193 |
# | Area (ha) | {stats_df['Area (ha)'].item():.2f} ha|
|
194 |
# | Perimeter (m) | {stats_df['Perimeter (m)'].item():.2f} m |"""
|
195 |
# unsafe_allow_html=True)
|
196 |
-
|
197 |
-
centroid_lat = stats_df["Centroid"].item().xy[1][0]
|
198 |
centroid_url = f"http://maps.google.com/maps?q={centroid_lat},{centroid_lon}&layer=satellite"
|
199 |
st.markdown(
|
200 |
f"""
|
|
|
177 |
zoom_to_layer=True,
|
178 |
style_function=lambda x: {"color": "red", "fillOpacity": 0.0},
|
179 |
)
|
|
|
180 |
|
181 |
# Metrics
|
182 |
+
stats_df = pd.DataFrame(index=[0])
|
183 |
stats_df["Points"] = str(json.loads(geometry_gdf.to_crs(4326).to_json())["features"][0]["geometry"]["coordinates"])
|
184 |
stats_df["Centroid"] = geometry_gdf.centroid.to_crs(4326).item()
|
185 |
stats_df["Area (ha)"] = geometry_gdf.geometry.area.item() / 10000
|
186 |
stats_df["Perimeter (m)"] = geometry_gdf.geometry.length.item()
|
187 |
+
centroid_lon = stats_df["Centroid"].item().xy[0][0]
|
188 |
+
centroid_lat = stats_df["Centroid"].item().xy[1][0]
|
189 |
|
190 |
+
centroid_gdf = gpd.GeoDataFrame(geometry=[stats_df["Centroid"].item()], crs="EPSG:4326")
|
191 |
+
m.add_gdf(
|
192 |
+
centroid_gdf,
|
193 |
+
layer_name="Centroid",
|
194 |
+
style_function=lambda x: {"color": "blue", "fillOpacity": 0.0},
|
195 |
+
zoom_to_layer=False,
|
196 |
+
)
|
197 |
+
m.to_streamlit(height=height)
|
198 |
st.write("<h3><div style='text-align: center;'>Geometry Metrics</div></h3>", unsafe_allow_html=True)
|
199 |
# st.markdown(
|
200 |
# f"""| Metric | Value |
|
|
|
202 |
# | Area (ha) | {stats_df['Area (ha)'].item():.2f} ha|
|
203 |
# | Perimeter (m) | {stats_df['Perimeter (m)'].item():.2f} m |"""
|
204 |
# unsafe_allow_html=True)
|
205 |
+
|
|
|
206 |
centroid_url = f"http://maps.google.com/maps?q={centroid_lat},{centroid_lon}&layer=satellite"
|
207 |
st.markdown(
|
208 |
f"""
|