Learn R Programming

maskRangeR (version 1.1)

focalCompare: Generate layers based on different focal windows

Description

Aids in exploring how different focal regions may affect masks.

Usage

focalCompare(layer, windowSizes, fun, mc.cores = 1)

Arguments

layer

A single raster layer to be summarized.

windowSizes

A vector of the number of cell in each direction to buffer for the focal summary. E.g., a value of 1 indicates the 8 cells immediately surrounding the focal cell, i.e., which are 1 cell away.

fun

The function fun should take multiple numbers, and return a single number. For example mean, modal, min or max. It should also accept a na.rm argument (or ignore it, e.g. as one of the 'dots' arguments. For example, length will fail, but function(x, ...)na.omit(length(x)) works. (Specifications from `raster::focal`)

mc.cores

Number of cores for (optional) parallelization

Value

Raster object

Details

See Examples.

Examples

Run this code
# NOT RUN {
r <- raster::raster(ncols=36, nrows=18, xmn=0)
r[] <- runif(raster::ncell(r)) 
r15 <- focalCompare(r, windowSizes = c(1:5),mc.cores=1,fun=mean) 
# }

Run the code above in your browser using DataLab