powered by
Apply a function over time and bands in a four-dimensional (band, time, y, x) array and reduce time dimension
# S3 method for array reduce_time(x, FUN, ...)
four-dimensional input array with dimensions band, time, y, x (in this order)
function which receives one time series in a two-dimensional array with dimensions bands, time as input
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.
d <- c(4,16,32,32) x <- array(rnorm(prod(d)), d) # reduce individual bands over pixel time series y <- reduce_time(x, function(v) { apply(v, 1, mean) }) dim(y)
Run the code above in your browser using DataLab