Hello,
>> I am using the function "focal" in the R package "raster" but I don’t >> understand how the function calculates values for neighboring cells that >> are located at the raster edge. Here is an example reproducible: focal is a method for the S4 object RasterLayer. You can have access to this method by using > findMethods("focal") and you can trace the method by using > trace(what='focal', tracer=browser, at=1, signature='RasterLayer') HTH, Jeremie >> } >> >> r <- raster(ncol=3, nrow=3) >> vals <- 1:ncell(r) >> r <- setValues(r, vals) >> plot(r) >> >> func_f <- focal(r, w=matrix(1,nrow=3,ncol=3), >> fun= func, pad = TRUE, padValue = NA) >> text(func_f ) >> getValues(func_f) >> >> >> From the example, I manage to find the value “2.06066”: >> >> c <- 5 >> >> (abs(1-c)*(1/sqrt(2)) + abs(2-c)*1 + abs(3-c)*(1/sqrt(2)) + >> >> abs(4-c)*1 + abs(5-c)*0 + abs(6-c)*1 + >> >> abs(7-c)*(1/sqrt(2)) + abs(8-c)*1 + abs(9-c)*(1/sqrt(2))) / 8 >> >> >> but I don’t manage to find the value “2.18566”. How can I find this value >> ? In addition, why does the function with “pad = TRUE” and without >> “pad=TRUE” give the same result ? >> >> Thank you very much for your time. >> >> Have a nice day >> >> Marine >> >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. Is >> helpful is >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.