UjjwalKGupta commited on
Commit
a36eb8d
1 Parent(s): 85fe8d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -121,11 +121,9 @@ def get_dem_slope_maps(buffer_ee_geometry):
121
 
122
  # Calculate the minimum and maximum values
123
  stats = contours.reduceRegion(reducer=ee.Reducer.minMax(),scale=30,maxPixels=1e13)
124
-
125
- # Print the results
126
  max_value = stats.get('contours_max').getInfo()
127
-
128
- vis_params = {"min": 0, "max": max_value, "palette": ["blue", "green", "yellow", "red"]}
129
  dem_map.addLayer(contours, vis_params, "Contours")
130
  # Create a colormap
131
  colormap = cm.LinearColormap(colors=vis_params['palette'], vmin=vis_params['min'], vmax=vis_params['max'])
@@ -134,8 +132,12 @@ def get_dem_slope_maps(buffer_ee_geometry):
134
  # Create the map for Slope
135
  slope_map = gee_folium.Map()
136
  # Calculate slope from the DEM
137
- slope_layer = ee.Terrain.slope(ee.Image("USGS/SRTMGL1_003")).clip(buffer_ee_geometry)
138
- vis_params = {"min": 0, "max": 20, "palette": ["blue", "green", "yellow", "red"]}
 
 
 
 
139
  slope_map.addLayer(slope_layer, vis_params, "Slope Layer")
140
  # Create a colormap
141
  colormap = cm.LinearColormap(colors=vis_params['palette'], vmin=vis_params['min'], vmax=vis_params['max'])
 
121
 
122
  # Calculate the minimum and maximum values
123
  stats = contours.reduceRegion(reducer=ee.Reducer.minMax(),scale=30,maxPixels=1e13)
 
 
124
  max_value = stats.get('contours_max').getInfo()
125
+ min_value = stats.get('contours_min').getInfo()
126
+ vis_params = {"min": min_value, "max": max_value, "palette": ["blue", "green", "yellow", "red"]}
127
  dem_map.addLayer(contours, vis_params, "Contours")
128
  # Create a colormap
129
  colormap = cm.LinearColormap(colors=vis_params['palette'], vmin=vis_params['min'], vmax=vis_params['max'])
 
132
  # Create the map for Slope
133
  slope_map = gee_folium.Map()
134
  # Calculate slope from the DEM
135
+ slope_layer = ee.Terrain.slope(ee.Image("USGS/SRTMGL1_003")).clip(buffer_ee_geometry).rename('slope')
136
+ # Calculate the minimum and maximum values
137
+ stats = slope_layer.reduceRegion(reducer=ee.Reducer.minMax(),scale=30,maxPixels=1e13)
138
+ max_value = stats.get('slope_max').getInfo()
139
+ min_value = stats.get('slope_min').getInfo()
140
+ vis_params = {"min": min_value, "max": max_value, "palette": ["blue", "green", "yellow", "red"]}
141
  slope_map.addLayer(slope_layer, vis_params, "Slope Layer")
142
  # Create a colormap
143
  colormap = cm.LinearColormap(colors=vis_params['palette'], vmin=vis_params['min'], vmax=vis_params['max'])