Image colorbar
In [ ]:
# !pip install geemap
In [ ]:
import ee
import geemap
import geemap.colormaps as cm
Colormap¶
In [ ]:
# geemap.update_package()
In [ ]:
cm.palettes.dem
In [ ]:
cm.palettes.ndvi
In [ ]:
cm.palettes.ndwi
In [ ]:
cm.get_palette('terrain', n_class=8)
In [ ]:
cm.plot_colormap('terrain', width=8.0, height=0.4, orientation='horizontal')
In [ ]:
cm.list_colormaps()
In [ ]:
cm.plot_colormaps(width=12, height=0.4)
Colorbar¶
In [ ]:
Map = geemap.Map()
palette = cm.palettes.dem
# palette = cm.palettes.terrain
dem = ee.Image('USGS/SRTMGL1_003')
vis_params = {
'min': 0,
'max': 4000,
'palette': palette}
Map.addLayer(dem, vis_params, 'SRTM DEM')
Map.add_colorbar(vis_params, label="Elevation (m)", layer_name="SRTM DEM")
Map
In [ ]:
Map.add_colorbar(vis_params, label="Elevation (m)", orientation="vertical", layer_name="SRTM DEM")
In [ ]:
Map.add_colorbar(vis_params, label="Elevation (m)", orientation="vertical", layer_name="SRTM DEM", transparent_bg=True)
In [ ]:
Map.add_colorbar(vis_params, discrete=True, label="Elevation (m)", orientation="vertical", layer_name="SRTM DEM")
Legend¶
In [ ]:
legends = geemap.builtin_legends
for legend in legends:
print(legend)
In [ ]:
Map = geemap.Map(basemap="HYBRID")
Map.add_basemap("FWS NWI Wetlands Raster")
Map.add_legend(builtin_legend="NWI")
Map
In [ ]:
Map = geemap.Map(basemap="HYBRID")
Map.add_basemap("NLCD 2016 CONUS Land Cover")
Map.add_legend(builtin_legend="NLCD")
Map
In [ ]:
Map = geemap.Map()
legend_dict = {
'11 Open Water': '466b9f',
'12 Perennial Ice/Snow': 'd1def8',
'21 Developed, Open Space': 'dec5c5',
'22 Developed, Low Intensity': 'd99282',
'23 Developed, Medium Intensity': 'eb0000',
'24 Developed High Intensity': 'ab0000',
'31 Barren Land (Rock/Sand/Clay)': 'b3ac9f',
'41 Deciduous Forest': '68ab5f',
'42 Evergreen Forest': '1c5f2c',
'43 Mixed Forest': 'b5c58f',
'51 Dwarf Scrub': 'af963c',
'52 Shrub/Scrub': 'ccb879',
'71 Grassland/Herbaceous': 'dfdfc2',
'72 Sedge/Herbaceous': 'd1d182',
'73 Lichens': 'a3cc51',
'74 Moss': '82ba9e',
'81 Pasture/Hay': 'dcd939',
'82 Cultivated Crops': 'ab6c28',
'90 Woody Wetlands': 'b8d9eb',
'95 Emergent Herbaceous Wetlands': '6c9fb8'
}
landcover = ee.Image('USGS/NLCD/NLCD2016').select('landcover')
Map.addLayer(landcover, {}, 'NLCD Land Cover')
Map.add_legend(title="NLCD Land Cover Classification", legend_dict=legend_dict, layer_name='NLCD Land Cover')
Map
Last update: 2021-03-17