Apply a map algebra script on a raster.
Signatures
RS_MapAlgebra (raster: Raster, pixelType: String, script: String)
RS_MapAlgebra (raster: Raster, pixelType: String, script: String, noDataValue: Double)
RS_MapAlgebra(rast0: Raster, rast1: Raster, pixelType: String, script: String, noDataValue: Double)
Parameters
The NoData value to use for pixels outside the raster extent.
Return type
Examples
Calculate the NDVI of a raster with 4 bands (R, G, B, NIR):
-- Assume that the input raster has 4 bands: R, G, B, NIR
-- rast[0] refers to the R band, rast[3] refers to the NIR band.
SELECT RS_MapAlgebra(rast, 'D', 'out = (rast[3] - rast[0]) / (rast[3] + rast[0]);') AS ndvi FROM raster_table
+--------------------+
| raster|
+--------------------+
|GridCoverage2D["g...|
+--------------------+
Spark SQL Example for two raster input RS_MapAlgebra:
RS_MapAlgebra(rast0, rast1, 'D', 'out = rast0[0] * 0.5 + rast1[0] * 0.5;', null)
For more details and examples about RS_MapAlgebra, please refer to the Map Algebra documentation.
To learn how to write map algebra script, please refer to Jiffle language summary.