UjjwalKGupta
commited on
Commit
•
bc64de4
1
Parent(s):
f8d91c2
Update app.py
Browse files
app.py
CHANGED
@@ -113,16 +113,27 @@ def get_dem_slope_maps(buffer_ee_geometry):
|
|
113 |
# Create the map for DEM
|
114 |
dem_map = gee_folium.Map()
|
115 |
dem_layer = ee.Image("USGS/SRTMGL1_003").clip(buffer_ee_geometry)
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
# Create a colormap
|
119 |
colormap = cm.LinearColormap(colors=vis_params['palette'], vmin=vis_params['min'], vmax=vis_params['max'])
|
120 |
dem_map.add_child(colormap)
|
121 |
-
dem_map.addLayer(buffer_ee_geometry, )
|
122 |
|
123 |
# Create the map for Slope
|
124 |
slope_map = gee_folium.Map()
|
125 |
-
|
|
|
126 |
vis_params = {"min": 0, "max": 20, "palette": ["blue", "green", "yellow", "red"]}
|
127 |
slope_map.addLayer(slope_layer, vis_params, "Slope Layer")
|
128 |
# Create a colormap
|
@@ -467,14 +478,9 @@ if "result" in st.session_state:
|
|
467 |
m.to_streamlit()
|
468 |
|
469 |
st.write("<h3><div style='text-align: center;'>DEM and Slope from SRTM at 30m resolution</div></h3>", unsafe_allow_html=True)
|
470 |
-
|
471 |
dem_map, slope_map = get_dem_slope_maps(ee.Geometry(buffer_geometry_gdf.to_crs(4326).geometry.item().__geo_interface__))
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
# Slope Map
|
478 |
-
slope_col.write("Slope Map")
|
479 |
-
slope_map.to_streamlit()
|
480 |
-
add_geometry_to_maps([slope_map])
|
|
|
113 |
# Create the map for DEM
|
114 |
dem_map = gee_folium.Map()
|
115 |
dem_layer = ee.Image("USGS/SRTMGL1_003").clip(buffer_ee_geometry)
|
116 |
+
|
117 |
+
# Generate contour lines using elevation thresholds
|
118 |
+
contour_interval = 10
|
119 |
+
contours = terrain.select('elevation').subtract(terrain.select('elevation').mod(contour_interval)).rename('contours')
|
120 |
+
|
121 |
+
# Calculate the minimum and maximum values
|
122 |
+
stats = dem_layer.reduceRegion(reducer=ee.Reducer.minMax(),scale=30,maxPixels=1e13)
|
123 |
+
|
124 |
+
# Print the results
|
125 |
+
max_value = stats.get('contours_max').getInfo()
|
126 |
+
|
127 |
+
vis_params = {"min": 0, "max": max_value, "palette": ["blue", "green", "yellow", "red"]}
|
128 |
+
dem_map.addLayer(contours, vis_params, "Contours")
|
129 |
# Create a colormap
|
130 |
colormap = cm.LinearColormap(colors=vis_params['palette'], vmin=vis_params['min'], vmax=vis_params['max'])
|
131 |
dem_map.add_child(colormap)
|
|
|
132 |
|
133 |
# Create the map for Slope
|
134 |
slope_map = gee_folium.Map()
|
135 |
+
# Calculate slope from the DEM
|
136 |
+
slope_layer = ee.Terrain.slope(ee.Image("USGS/SRTMGL1_003")).clip(buffer_ee_geometry)
|
137 |
vis_params = {"min": 0, "max": 20, "palette": ["blue", "green", "yellow", "red"]}
|
138 |
slope_map.addLayer(slope_layer, vis_params, "Slope Layer")
|
139 |
# Create a colormap
|
|
|
478 |
m.to_streamlit()
|
479 |
|
480 |
st.write("<h3><div style='text-align: center;'>DEM and Slope from SRTM at 30m resolution</div></h3>", unsafe_allow_html=True)
|
481 |
+
cols = st.columns(2)
|
482 |
dem_map, slope_map = get_dem_slope_maps(ee.Geometry(buffer_geometry_gdf.to_crs(4326).geometry.item().__geo_interface__))
|
483 |
+
for col, param_map in zip(cols, [dem_map, slope_map]):
|
484 |
+
with col:
|
485 |
+
add_geometry_to_maps([param_map])
|
486 |
+
param_map.to_streamlit()
|
|
|
|
|
|
|
|
|
|