mw_create: Create focal ("moving window") weight matrix

View source: R/utils.R

mw_createR Documentation

Create focal ("moving window") weight matrix

Description

Create a focal ("moving window") weight matrix for use in terra::focal().

Usage

mw_create(r, radius)

Arguments

r

SpatRaster.

radius

radius of the circle (in units of the crs).

Details

The returned mask includes raster-cell centres whose Euclidean distance from the focal-cell centre is no greater than 'radius' plus the full raster-cell diagonal. This conservative expansion accounts for the possible displacement of both a disk centre and a contributing point from their respective cell centres.

Author(s)

Martin Haringa


spatialrisk documentation built on Oct. 16, 2026, 5:09 p.m.