focal_mean | R Documentation |
Low-pass filtering by a square window in the image processing. Focal operation of map algebra. Weight of pixels is proportional to cell area inside of focal window.
focal_mean(x, size = 3.0, cover = 1e-06, fillNA = FALSE, saveMargin = TRUE ,noNA = TRUE, verbose = 0L)
x |
Object of class |
size |
Positive numeric. Size of square focal window. Fractional values are allowed. If |
cover |
Numeric. |
fillNA |
Logical. If |
saveMargin |
Logical. If |
noNA |
Logical. If |
verbose |
Integer of |
The reference is always central pixel, even if window size is even.
If size=3
then multiplicator is 3^(-2)
and elements have equal weights:
[,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1
If size=2
then multiplicator is 2^(-2)
and weights of elements are:
[,1] [,2] [,3] [1,] 0.25 0.50 0.25 [2,] 0.50 1.00 0.50 [3,] 0.25 0.50 0.25
If size=3.4
then multiplicator is 3.4^(-2)
and weights of elements are:
[,1] [,2] [,3] [,4] [,5] [1,] 0.04 0.20 0.20 0.20 0.04 [2,] 0.20 1.00 1.00 1.00 0.20 [3,] 0.20 1.00 1.00 1.00 0.20 [4,] 0.20 1.00 1.00 1.00 0.20 [5,] 0.04 0.20 0.20 0.20 0.04
Object of class ursaRaster
with the same number of bands as in input raster.
Nikita Platonov platonov@sevin.ru
session_grid(NULL) a <- ursa_dummy(nband=1,mul=1/8,elements=0) a[a<80] <- NA print(a) b1 <- focal_mean(a,size=6,cover=0.5,saveMargin=FALSE) b2 <- focal_mean(a,size=6,cover=0.5,saveMargin=TRUE) b3 <- focal_mean(a,size=6,cover=0.5,saveMargin=TRUE,fillNA=TRUE) print(b3-a) display(c(a,b1,b2,b3),blank.angle=c(-45,45),blank.density=20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.