focal3D | R Documentation |
Calculate focal ("moving window") values for the three-dimensional neighborhood (window) of focal cells. See focal
for two-dimensional focal computation.
## S4 method for signature 'SpatRaster'
focal3D(x, w=3, fun=mean, ..., na.policy="all", fillvalue=NA, pad=FALSE,
padvalue=fillvalue, expand=FALSE, silent=TRUE,
filename="", overwrite=FALSE, wopt=list())
x |
SpatRaster |
w |
window. A rectangular prism (cuboid) defined by three numbers or by a three-dimensional array. The values are used as weights, and are usually zero, one, NA, or fractions. The window used must have odd dimensions. If you desire to use even sides, you can use an array, and pad the values with rows and/or columns that contain only |
fun |
function that takes multiple numbers, and returns one or multiple numbers for each focal area. For example mean, modal, min or max |
... |
additional arguments passed to |
na.policy |
character. Can be used to determine the cells of |
fillvalue |
numeric. The value of the cells in the virtual rows and columns outside of the raster |
pad |
logical. Add virtual layers before the first and after the last layer |
padvalue |
numeric. The value of the cells in the virtual layers |
expand |
logical. Add virtual layers before the first or after the last layer that are the same as the first or last layers. If |
silent |
logical. If |
filename |
character. Output filename |
overwrite |
logical. If |
wopt |
additional arguments for writing files as in |
SpatRaster
focal
r <- rast(system.file("ex/logo.tif", package="terra"))
x <- focal3D(r, c(5,5,3), na.rm=TRUE)
a <- array(c(0,1,0,1,1,1,0,1,0, rep(1,9), 0,1,0,1,1,1,0,1,0), c(3,3,3))
a[a==0] <- NA
z <- focal3D(r, a, na.rm=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.