powered by
Apply a function over pixels in a four-dimensional (band, time, y, x) array
# S3 method for array apply_pixel(x, FUN, ...)
four-dimensional input array with dimensions band, time, y, x (in this order)
function that receives a vector of band values in a one-dimensional array
further arguments passed to FUN
FUN is expected to produce a numeric vector (or scalar) where elements are interpreted as new bands in the result.
# NOT RUN { d <- c(4,16,32,32) x <- array(rnorm(prod(d)), d) y <- apply_pixel(x, function(v) { v[1] + v[2] + v[3] - v[4] }) dim(y) # }
Run the code above in your browser using DataLab