Builtin Library
README.md
core.raster.reduce (procNode)
Fold a layer of a raster to one number: the sum, mean, least or greatest of its cells.
Built from core.raster.read and core.reduce.
Inputs
raster(Raster). The raster folded.layer(String). Default"height". The layer folded.op(one of sum, mean, min, max). Default"sum". How the cells fold.
Outputs
value: the folded number.
Example
local raster = g.core.raster.new({ size = { x = 8, z = 8 }, resolution = 1, layers = { "height" } })
local raised = g.core.raster.blend({ raster = raster, value = 1.0 })
local mean = g.core.raster.reduce({ raster = raised, layer = "height", op = "mean" })
Every cell is 1 after the blend, so the mean is 1.