UjjwalKGupta
commited on
Commit
•
90e317e
1
Parent(s):
162af94
Fix NDVI Legend
Browse files
app.py
CHANGED
@@ -159,17 +159,12 @@ def get_dem_slope_maps(buffer_ee_geometry):
|
|
159 |
dem_map.addLayer(contours, vis_params, "Contours")
|
160 |
# Create a colormap
|
161 |
cmap = cm.LinearColormap(colors=vis_params["palette"], vmin=vis_params["min"], vmax=vis_params["max"])
|
162 |
-
#dem_map.add_child(colormap)
|
163 |
-
#dem_map.add_colormap(width=4,vmin=min_value, vmax=max_value, palette=vis_params['palette'],
|
164 |
-
# vis_params=vis_params, label='Elevation(m)',
|
165 |
-
# discrete=False, tick_size=10, bg_color='white',
|
166 |
-
# transparent=True, orientation='horizontal')
|
167 |
tick_size = int((max_value-min_value)/4)
|
168 |
dem_map.add_legend(title="Elevation (m)",
|
169 |
legend_dict={'{}-{} m'.format(min_value, min_value+tick_size): '#0000FF',
|
170 |
'{}-{} m'.format(min_value+tick_size, min_value+2*tick_size): '#00FF00',
|
171 |
'{}-{} m'.format(min_value+2*tick_size, min_value+3*tick_size): '#FFFF00',
|
172 |
-
'{}-{} m'.format(min_value+3*tick_size, max_value): 'FF0000'},
|
173 |
position='bottomright')
|
174 |
|
175 |
# Create the map for Slope
|
@@ -194,13 +189,12 @@ def get_dem_slope_maps(buffer_ee_geometry):
|
|
194 |
slope_map.addLayer(slope_layer, vis_params, "Slope Layer")
|
195 |
# Create a colormap
|
196 |
colormap = cm.LinearColormap(colors=vis_params["palette"], vmin=vis_params["min"], vmax=vis_params["max"])
|
197 |
-
#slope_map.add_child(colormap)
|
198 |
tick_size=int((max_value-min_value)/4)
|
199 |
slope_map.add_legend(title="Slope (degrees)",
|
200 |
legend_dict={'{}-{} deg'.format(min_value, min_value+tick_size): '#0000FF',
|
201 |
'{}-{} deg'.format(min_value+tick_size, min_value+2*tick_size): '#00FF00',
|
202 |
'{}-{} deg'.format(min_value+2*tick_size, min_value+3*tick_size): '#FFFF00',
|
203 |
-
'{}-{} deg'.format(min_value+3*tick_size, max_value): 'FF0000'},
|
204 |
position='bottomright')
|
205 |
return dem_map, slope_map
|
206 |
|
@@ -529,6 +523,18 @@ if "result" in st.session_state:
|
|
529 |
else:
|
530 |
raise ValueError(f"Unknown satellite: {satellite}")
|
531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
m.add_layer(mosaic.select(veg_index), vis_params)
|
533 |
# add colorbar
|
534 |
# m.add_colorbar(colors=["#000000", "#00FF00"], vmin=0.0, vmax=1.0)
|
|
|
159 |
dem_map.addLayer(contours, vis_params, "Contours")
|
160 |
# Create a colormap
|
161 |
cmap = cm.LinearColormap(colors=vis_params["palette"], vmin=vis_params["min"], vmax=vis_params["max"])
|
|
|
|
|
|
|
|
|
|
|
162 |
tick_size = int((max_value-min_value)/4)
|
163 |
dem_map.add_legend(title="Elevation (m)",
|
164 |
legend_dict={'{}-{} m'.format(min_value, min_value+tick_size): '#0000FF',
|
165 |
'{}-{} m'.format(min_value+tick_size, min_value+2*tick_size): '#00FF00',
|
166 |
'{}-{} m'.format(min_value+2*tick_size, min_value+3*tick_size): '#FFFF00',
|
167 |
+
'{}-{} m'.format(min_value+3*tick_size, max_value): '#FF0000'},
|
168 |
position='bottomright')
|
169 |
|
170 |
# Create the map for Slope
|
|
|
189 |
slope_map.addLayer(slope_layer, vis_params, "Slope Layer")
|
190 |
# Create a colormap
|
191 |
colormap = cm.LinearColormap(colors=vis_params["palette"], vmin=vis_params["min"], vmax=vis_params["max"])
|
|
|
192 |
tick_size=int((max_value-min_value)/4)
|
193 |
slope_map.add_legend(title="Slope (degrees)",
|
194 |
legend_dict={'{}-{} deg'.format(min_value, min_value+tick_size): '#0000FF',
|
195 |
'{}-{} deg'.format(min_value+tick_size, min_value+2*tick_size): '#00FF00',
|
196 |
'{}-{} deg'.format(min_value+2*tick_size, min_value+3*tick_size): '#FFFF00',
|
197 |
+
'{}-{} deg'.format(min_value+3*tick_size, max_value): '#FF0000'},
|
198 |
position='bottomright')
|
199 |
return dem_map, slope_map
|
200 |
|
|
|
523 |
else:
|
524 |
raise ValueError(f"Unknown satellite: {satellite}")
|
525 |
|
526 |
+
if veg_index=='NDVI':
|
527 |
+
m.add_legend(title="NDVI Class/Value",
|
528 |
+
legend_dict={'<0:Waterbody': '#0000FF',
|
529 |
+
'0-0.1: Open': '#FF0000',
|
530 |
+
'0.1-0.2: Highly Degraded':'#FFFF00',
|
531 |
+
'0.2-0.3: Degraded': '#FFA500',
|
532 |
+
'0.3-0.4: Moderately Degraded': '#00FE00',
|
533 |
+
'0.4-0.5: Dense': '#00A400',
|
534 |
+
'>0.5: Very Dense': '#006D00',
|
535 |
+
},
|
536 |
+
position='bottomright')
|
537 |
+
|
538 |
m.add_layer(mosaic.select(veg_index), vis_params)
|
539 |
# add colorbar
|
540 |
# m.add_colorbar(colors=["#000000", "#00FF00"], vmin=0.0, vmax=1.0)
|