Skip to main content
Adds a new band to a raster toRaster at a specified index toRasterIndex. The new band’s values are copied from fromRaster at a specified band index fromBand. If no toRasterIndex is provided, the new band is appended to the end of toRaster. If no fromBand is specified, band 1 from fromRaster is copied by default.
IllegalArgumentException will be thrown in these cases:
  • The provided Rasters, toRaster & fromRaster don’t have same shape.
  • The provided fromBand is not in fromRaster.
  • The provided toRasterIndex is not in or at end of toRaster.

Signatures

RS_AddBand(toRaster: Raster, fromRaster: Raster, fromBand: Integer = 1, toRasterIndex: Integer = at_end)
RS_AddBand(toRaster: Raster, fromRaster: Raster, fromBand: Integer = 1)
RS_AddBand(toRaster: Raster, fromRaster: Raster)

Parameters

toRaster
Raster
required
The target raster.
fromRaster
Raster
required
The source raster.
fromBand
Integer
default:"1"
The band index to copy from the source raster.
toRasterIndex
Integer
default:"at_end"
The index in the target raster to insert the band.

Return type

The resulting raster.

Example

SELECT RS_AddBand(raster1, raster2, 2, 1) FROM rasters
GridCoverage2D["g...