ee.Image.addBands

Retorna uma imagem com todas as bandas copiadas da primeira entrada e as bandas selecionadas da segunda entrada, substituindo opcionalmente as bandas na primeira imagem com o mesmo nome. A nova imagem tem os metadados e a área da primeira imagem de entrada.

UsoRetorna
Image.addBands(srcImg, names, overwrite)Imagem
ArgumentoTipoDetalhes
isso: dstImgImagemUma imagem em que as bandas serão copiadas.
srcImgImagemUma imagem que contém bandas a serem copiadas.
namesLista, padrão: nuloLista opcional de nomes de bandas a serem copiados. Se "names" for omitido, todas as bandas de "srcImg" serão copiadas.
overwriteBooleano, padrão: falsoSe for "true", as bandas de "srcImg" vão substituir as bandas com os mesmos nomes em "dstImg". Caso contrário, a nova banda será renomeada com um sufixo numérico ("foo" para "foo_1", a menos que "foo_1" exista, então "foo_2", a menos que exista, etc.).

Exemplos

Editor de código (JavaScript)

// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
print('Original image', img);

// Scale reflectance bands and overwrite the original bands.
var reflBands = img.select('B.*').divide(10000);
img = img.addBands({
  srcImg: reflBands,
  overwrite: true
});

// Compute and add a single band (NDVI).
var ndvi = img.normalizedDifference(['B8', 'B4']).rename('NDVI');
img = img.addBands(ndvi);

// Compute and add multiple bands (NDWI and NBR).
var ndwi = img.normalizedDifference(['B3', 'B8']).rename('NDWI');
var nbr = img.normalizedDifference(['B8', 'B12']).rename('NBR');
var newBands = ee.Image([ndwi, nbr]);
img = img.addBands(newBands);

print('Image with added/modified bands', img);

Configuração do Python

Consulte a página Ambiente Python para informações sobre a API Python e como usar geemap para desenvolvimento interativo.

import ee
import geemap.core as geemap

Colab (Python)

# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
print('Original image:', img.getInfo())

# Scale reflectance bands and overwrite the original bands.
refl_bands = img.select('B.*').divide(10000)
img = img.addBands(srcImg=refl_bands, overwrite=True)

# Compute and add a single band (NDVI).
ndvi = img.normalizedDifference(['B8', 'B4']).rename('NDVI')
img = img.addBands(ndvi)

# Compute and add multiple bands (NDWI and NBR).
ndwi = img.normalizedDifference(['B3', 'B8']).rename('NDWI')
nbr = img.normalizedDifference(['B8', 'B12']).rename('NBR')
new_bands = ee.Image([ndwi, nbr])
img = img.addBands(new_bands)

print('Image with added/modified bands:', img.getInfo())