RS_AddBandFromArray¶
Introduction: Add a band to a raster from an array of doubles.
Format:
RS_AddBandFromArray (raster: Raster, band: ARRAY[Double])
RS_AddBandFromArray (raster: Raster, band: ARRAY[Double], bandIndex: Integer)
RS_AddBandFromArray (raster: Raster, band: ARRAY[Double], bandIndex: Integer, noDataValue: Double)
Since: v1.5.0
The bandIndex is 1-based and must be between 1 and RS_NumBands(raster) + 1. It throws an exception if the bandIndex is out of range or the raster is null. If not specified, the noDataValue of the band is assumed to be null.
When the bandIndex is RS_NumBands(raster) + 1, it appends the band to the end of the raster. Otherwise, it replaces the existing band at the bandIndex.
If the bandIndex and noDataValue is not given, a convenience implementation adds a new band with a null noDataValue.
Adding a new band with a custom noDataValue requires bandIndex = RS_NumBands(raster) + 1 and non-null noDataValue to be explicitly specified.
Modifying or Adding a customNoDataValue is also possible by giving an existing band in RS_AddBandFromArray
In order to remove an existing noDataValue from an existing band, pass null as the noDataValue in the RS_AddBandFromArray.
Note that: bandIndex == RS_NumBands(raster) + 1 is an experimental feature and might lead to the loss of raster metadata and properties such as color models.
Note
RS_AddBandFromArray typecasts the double band values to the given datatype of the raster. This can lead to overflow values if values beyond the range of the raster's datatype are provided.
SQL Example
SELECT RS_AddBandFromArray(raster, RS_MultiplyFactor(RS_BandAsArray(RS_FromGeoTiff(content), 1), 2)) AS raster FROM raster_table
SELECT RS_AddBandFromArray(raster, RS_MultiplyFactor(RS_BandAsArray(RS_FromGeoTiff(content), 1), 2), 1) AS raster FROM raster_table
SELECT RS_AddBandFromArray(raster, RS_MultiplyFactor(RS_BandAsArray(RS_FromGeoTiff(content), 1), 2), 1, -999) AS raster FROM raster_table
Output:
+--------------------+
| raster|
+--------------------+
|GridCoverage2D["g...|
+--------------------+