Skip to main content
Stack a given array of rasters into a single raster. The rasters are stacked in the order they are provided in the array. The function also explodes the stacked raster into multiple tiles. This function handles rasters that are not aligned and having different resolutions, data types and coordinate reference systems:
  • The CRS and resolution of the output raster will be the same as the selected reference raster.
  • The data type of the output raster will be the most precise data type among all stacked bands.

Signatures

RS_StackTileExplode(rasters: Array[Raster], refRasterIndex: Integer, tileWidth: Integer, tileHeight: Integer, padWithNoData: Boolean = false, noDataValue: Double = NaN)

Parameters

rasters
Array[Raster]
required
An array of rasters to be stacked.
refRasterIndex
Integer
required
The zero-based index of the reference raster in the array of rasters. The CRS and resolution of the output raster will be the same as the reference raster. If refRasterIndex is -1, the last raster in the array will be used as the reference raster.
tileWidth
Integer
required
The width of the tiles in the output raster.
tileHeight
Integer
required
The height of the tiles in the output raster.
padWithNoData
Boolean
default:"false"
A boolean flag to determine whether to pad the output raster with no data values. If padWithNoData is true, the output raster will be padded with noDataValue.
noDataValue
Double
default:"NaN"
The no data value to use when padding the output raster.

Return type

A struct containing the result fields.

Example

SELECT RS_StackTileExplode(ARRAY(RS_FromPath('/path/to/raster1.tif'), RS_FromPath('/path/to/raster2.tif')), 0, 100, 100, true, 255)
+---+---+--------------------+
|  x|  y|                tile|
+---+---+--------------------+
|  0|  0|GridCoverage2D["g...|
|  1|  0|GridCoverage2D["g...|
|  2|  0|GridCoverage2D["g...|
|  0|  1|GridCoverage2D["g...|
|  1|  1|GridCoverage2D["g...|
|  2|  1|GridCoverage2D["g...|
|  0|  2|GridCoverage2D["g...|
|  1|  2|GridCoverage2D["g...|
|  2|  2|GridCoverage2D["g...|
+---+---+--------------------+