focalCompare | R Documentation |
Aids in exploring how different focal regions may affect masks.
focalCompare(layer, windowSizes, fun, mc.cores = 1)
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 |
See Examples.
Raster object
This may be particularly useful if for mobile species when their movement patterns cover a much larger extent than the single cell in which they were observed.
Cory Merow <cory.merow@gmail.com>,
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.