Image colorbar
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
In [2]:
Copied!
import ee
import geemap
import geemap.colormaps as cm
import ee
import geemap
import geemap.colormaps as cm
Colormap¶
In [3]:
Copied!
# geemap.update_package()
# geemap.update_package()
In [4]:
Copied!
cm.palettes.dem
cm.palettes.dem
Out[4]:
('006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5')
In [5]:
Copied!
cm.palettes.ndvi
cm.palettes.ndvi
Out[5]:
('FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301')
In [6]:
Copied!
cm.palettes.ndwi
cm.palettes.ndwi
Out[6]:
('#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858')
In [7]:
Copied!
cm.get_palette('terrain', n_class=8)
cm.get_palette('terrain', n_class=8)
Out[7]:
['333399', '0294fa', '24d36d', 'b6f08a', 'dbd085', '92735e', 'b6a29d', 'ffffff']
In [8]:
Copied!
cm.plot_colormap('terrain', width=8.0, height=0.4, orientation='horizontal')
cm.plot_colormap('terrain', width=8.0, height=0.4, orientation='horizontal')
In [9]:
Copied!
cm.list_colormaps()
cm.list_colormaps()
Out[9]:
['Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r']
In [10]:
Copied!
cm.plot_colormaps(width=12, height=0.4)
cm.plot_colormaps(width=12, height=0.4)
Colorbar¶
In [11]:
Copied!
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
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
Out[11]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [12]:
Copied!
Map.add_colorbar(
vis_params, label="Elevation (m)", orientation="vertical", layer_name="SRTM DEM"
)
Map.add_colorbar(
vis_params, label="Elevation (m)", orientation="vertical", layer_name="SRTM DEM"
)
In [13]:
Copied!
Map.add_colorbar(
vis_params,
label="Elevation (m)",
orientation="vertical",
layer_name="SRTM DEM",
transparent_bg=True,
)
Map.add_colorbar(
vis_params,
label="Elevation (m)",
orientation="vertical",
layer_name="SRTM DEM",
transparent_bg=True,
)
In [14]:
Copied!
Map.add_colorbar(
vis_params,
discrete=True,
label="Elevation (m)",
orientation="vertical",
layer_name="SRTM DEM",
)
Map.add_colorbar(
vis_params,
discrete=True,
label="Elevation (m)",
orientation="vertical",
layer_name="SRTM DEM",
)
Legend¶
In [15]:
Copied!
legends = geemap.builtin_legends
for legend in legends:
print(legend)
legends = geemap.builtin_legends
for legend in legends:
print(legend)
NLCD ESA_WorldCover ESRI_LandCover NWI MODIS/051/MCD12Q1 MODIS/006/MCD12Q1 GLOBCOVER JAXA/PALSAR Oxford AAFC/ACI COPERNICUS/CORINE/V20/100m COPERNICUS/Landcover/100m/Proba-V/Global USDA/NASS/CDL
In [16]:
Copied!
Map = geemap.Map(basemap="HYBRID")
Map.add_basemap("FWS NWI Wetlands Raster")
Map.add_legend(builtin_legend="NWI")
Map
Map = geemap.Map(basemap="HYBRID")
Map.add_basemap("FWS NWI Wetlands Raster")
Map.add_legend(builtin_legend="NWI")
Map
Out[16]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [17]:
Copied!
Map = geemap.Map(basemap="HYBRID")
Map.add_basemap("NLCD 2016 CONUS Land Cover")
Map.add_legend(builtin_legend="NLCD")
Map
Map = geemap.Map(basemap="HYBRID")
Map.add_basemap("NLCD 2016 CONUS Land Cover")
Map.add_legend(builtin_legend="NLCD")
Map
Out[17]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [18]:
Copied!
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
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
Out[18]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Last update:
2022-03-25