Learn R Programming

terra (version 0.8-5)

focalMat: Focal weights matrix

Description

Make a focal ("moving window") weight matrix for use in the focal function. The sum of the values adds up to one.

Usage

focalMat(x, d, type=c('circle', 'Gauss', 'rectangle'))

Arguments

x

SpatRaster

d

numeric. If type=circle, the radius of the circle (in units of the crs). If type=rectangle the dimension of the rectangle (one or two numbers). If type=Gauss the size of sigma, and optionally another number to determine the size of the matrix returned (default is 3*sigma)

type

character indicating the type of filter to be returned

Value

matrix that can be used with focal

Examples

Run this code
# NOT RUN {
r <- rast(ncols=36, nrows=18, xmn=0)
# Gaussian filter for square cells
gf <- focalMat(r, 2, "Gauss")
# }

Run the code above in your browser using DataLab