Skip to content
Prev 22368 / 29559 Next

pixel-wsie correlation between raster stack and numeric vector?

MIke, I think you can use the 'calc' function for that:

library(raster)
# example data
set.seed(0)
s <- stack(system.file("external/rlogo.grd", package="raster"))
s <- stack(s, s[[1]]*runif(ncell(s)), s[[2]]*runif(ncell(s))/10,
s[[3]]*runif(ncell(s))+10)

# example vector
v <- 1:6

x <- calc(s, fun=function(x) cor(x, v))
plot(x)

Robert
On Mon, Feb 23, 2015 at 1:14 PM, Mike Loranty <mloranty at colgate.edu> wrote: