focal_bylayer: Apply raster's focal function by layer

View source: R/focal_bylayer.R

focal_bylayerR Documentation

Apply raster's focal function by layer

Description

Apply's raster's focal function to layers in a brick or stack. See help for focal for more information on paramater behaviour.

Usage

focal_bylayer(
  x,
  w,
  fun,
  na.rm = FALSE,
  pad = FALSE,
  padValue = NA,
  NAonly = FALSE,
  cl = NULL,
  ...
)

Arguments

x

A RasterBrick or RasterStack

w

Focal weights as required by focal

fun

Function to apply to value in focal region

na.rm

If TRUE NA values removed from computations.

pad

Passed to raster::focal(). If TRUE, additional 'virtual' rows and columns are padded to x such that there are no edge effects. This can be useful when a function needs to have access to the central cell of the filter.

padValue

Passed to raster::focal(). The value of the cells of the padded rows and columns.

NAonly

Passed to raster::focal(). If TRUE, only cell values that are NA are replaced with the computed focal values.

cl

a cluster for parallel computation created par parallel. If NULL then no parallel computations will occur.

Value

A RasterBrick with each layer the output raster::focal() applied to a layer of the input brick


sustainablefarms/sflddata documentation built on April 19, 2022, 11:19 a.m.