This alternative to raster::mask is included here.

fastMask(
x,
y,
cores = NULL,
useGDAL = getOption("reproducible.useGDAL", FALSE),
verbose = getOption("reproducible.verbose", 1),
...,
skipDeprecastedMsg = FALSE
)

Arguments

x

A Raster* object.

y

A SpatialPolygons object. If it is not in the same projection as x, it will be reprojected on the fly to that of x

cores

An integer* or 'AUTO'. This will be used if gdalwarp is triggered. 'AUTO' will calculate 90% of the total number of cores in the system, while an integer or rounded float will be passed as the exact number of cores to be used.

useGDAL

Logical or "force". This is defunct; internals now can use terra if options("reproducible.useTerra" = TRUE), which is not (yet) the default.

verbose

Numeric, -1 silent (where possible), 0 being very quiet, 1 showing more messaging, 2 being more messaging, etc. Default is 1. Above 3 will output much more information about the internals of Caching, which may help diagnose Caching challenges. Can set globally with an option, e.g., options('reproducible.verbose' = 0) to reduce to minimal

...

Currently unused.

skipDeprecastedMsg

Logical. If TRUE, then the message about this function being deprecated will be suppressed.

Value

A Raster* object, masked (i.e., smaller extent and/or several pixels converted to NA)

Eliot McIntire