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:
Hi All, Is there a way (e.g. existing function) to calculate correlation coefficients between a raster stack and a numeric vector? For example, between gridded vegetation indices and a vector of atmospheric oscillation indices (e.g. ENSO, NAO, etc...). Thanks, Michael Loranty Assistant Professor Department of Geography Colgate University 315.228.6057 mloranty at colgate.edu http://mikeloranty.wordpress.com/ [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo