I am using this code to calculate the moving average mean.It worked fine but when I wanted to also calculate based on sd(stander deviation) I got the error shown below. I read this documentation of R movingFun and found that sd was mentioned at http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/raster/html/movingFun.html
I wonder if needs any other things to conseder or sd is not at all supplied by this function. sami<- list.files("C:\\Usersfinal-2010", "*.envi", full.names = TRUE) saf=stack(sami) dm <- overlay(saf ,fun=function(x) movingFun(x, fun=mean, n=3, na.rm=TRUE,fill=NA)) ### worked very well ds <- overlay(saf ,fun=function(x) movingFun(x, fun= sd, n=3, na.rm=TRUE)) ### did not work Error in .overlayList(x, fun = fun, filename = filename, ...) : cannot use this formula, probably because it is not vectorized > saf class : RasterStack dimensions : 720, 1440, 1036800, 12 (nrow, ncol, ncell, nlayers) resolution : 0.25, 0.25 (x, y) extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 names : SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, SM_RE01_M//7_amenlast, -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-the-rolling-standard-deviation-in-rasters-tp4661819.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.