Image overview
Image Overview
Raster data are represented as Image
objects in Earth Engine. Images are composed of one or more bands and each band has its own name, data type, scale, mask and projection. Each image has metadata stored as a set of properties.
In addition to loading images from the archive by an image ID, you can also create images from constants, lists or other suitable Earth Engine objects. The following illustrates methods for creating images, getting band subsets, and manipulating bands.
More information about ee.Image can be found in the Earth Engine Documentation.
# !pip isntall geemap
import ee
import geemap
Loading a single-band image¶
Images can be loaded by pasting an Earth Engine asset ID into the ee.Image constructor. You can find image IDs in the data catalog. For example, to load SRTM Digital Elevation Data:
Map = geemap.Map(center=(40, -100), zoom=4)
Map
dem = ee.Image('CGIAR/SRTM90_V4')
Map.addLayer(dem, {}, "DEM")
# Set visualization parameters.
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}
Map.addLayer(dem, vis_params, "DEM Vis")
Loading a multi-band image¶
Map = geemap.Map()
# Load an image.
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
# Center the map and display the image.
Map.centerObject(image, zoom=8)
Map.addLayer(image, {}, 'Landsat')
Map
vis_params = {'bands': ['B5', 'B4', 'B3'], 'min': 0.0, 'max': 3000, 'opacity': 1.0, 'gamma': 1.2}
Map.addLayer(image, vis_params, "Landsat Vis")
Getting image properties¶
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
props = geemap.image_props(image)
props.getInfo()
Selecting image bands¶
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
bands = image.select(['B5', 'B4', 'B3'])
Map.addLayer(bands, vis_params, 'Landsat B543')
Map
Renaming band names¶
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
new_image = image.select(['B5', 'B4', 'B3'], ['NIR', 'Red', 'Green'])
band_names = new_image.bandNames()
band_names.getInfo()
Adding a legend¶
Map = geemap.Map()
Map.add_basemap('HYBRID')
Map
landcover = ee.Image('USGS/NLCD/NLCD2016').select('landcover')
Map.addLayer(landcover, {}, 'Land Cover')
Map.add_legend(builtin_legend='NLCD', layer_name='Land Cover')