Returns an image containing all bands copied from the first input and selected bands from the second input, optionally overwriting bands in the first image with the same name. The new image has the metadata and footprint from the first input image.

Image.addBands(srcImg, names, overwrite)Image
this: dstImgImage

An image into which to copy bands.


An image containing bands to copy.

namesList, default: null

Optional list of band names to copy. If names is omitted, all bands from srcImg will be copied over.

overwriteBoolean, default: false

If true, bands from `srcImg` will override bands with the same names in `dstImg`. Otherwise the new band will be renamed with a numerical suffix (`foo` to `foo_1` unless `foo_1` exists, then `foo_2` unless it exists, etc).


Code Editor (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 orginal bands.
var reflBands ='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);