fill_na: Modify NAs within neighbourhood of data cells

View source: R/fill_na.R

fill_naR Documentation

Modify NAs within neighbourhood of data cells

Description

Apply a function to NA cells within a moving window.

Usage

fill_na(x, fun, w, outfile, return_rast = FALSE, overwrite = FALSE)

Arguments

x

A Raster* object.

fun

The function (name or symbol) to apply to the moving windows. First argument should represent the vector of cells contained in the focal window. Only non-NA cell values will be passed to the function.

w

A weights matrix (see raster::focalWeight() and raster::focal() defining the focal window to which fun will be applied. Note that all contributing cells will be given equal weight (i.e. varying weights are not respected - non-zero & non-NA weights will be replaced by 1).

outfile

Character. File path to an output raster file. If missing, a temporary file will be used.

return_rast

Logical. Should the RasterLayer be returned to R?

overwrite

Logical. Should outfile be replaced if it already exists?

Details

NA values within focal blocks will be ignored. Raster edges will be NA-padded to allow focal computations at the edge (see raster::focal().

Value

Returns the resulting RasterLayer if return_rast is TRUE. Returns the output file path otherwise.


jscamac/edmaps documentation built on June 11, 2022, 1:26 a.m.