matchExtent: Match the extent of a reference raster

Description Usage Arguments Details Value See Also Examples

View source: R/matchExtent.R

Description

This function crops or extends the extent of a raster to the extent of a reference. Some cells of the reference raster can optionally be masked based on their values.

Usage

1
2
3
4
5
6
7
8
9
matchExtent(
  x,
  ref,
  mask = FALSE,
  inverse = FALSE,
  maskValue = NA,
  filename = "",
  ...
)

Arguments

x

Raster* object or list of Raster* objects.

ref

Raster* object. x extent will be matched to ref extent.

mask

Logical. Should x be masked by ref cells that have the value maskValue

inverse

Logical. If TRUE, cells of ref that are not maskvalue are masked

maskValue

Value of ref cells that should be masked in x. Default is NA.

filename

Character. Output file name including path to directory and eventually extension. If x is a list, filename must be a vector of characters with one file name for each element of x. Default is "" (output not written to disk).

...

Other arguments passed to writeRaster

Details

x and ref need to have the same CRS, spatial resolution and origin. If this is not the case, you can use matchResolution before matchExtent.

Value

Raster* object or list of Raster* objects.

See Also

crop, extend, mask

Examples

1
2
3
4
5
6
7
8
# Load raster package
library(raster)

# Open ALS p95 and mask of forested areas as Raster objects
BAP_2006 <- stack(system.file("extdata/examples/Landsat_BAP_2006.tif",package="foster"))
mask_forest <- raster(system.file("extdata/examples/VLCE_forest_2008.tif",package="foster"))

matchExtent(BAP_2006, mask_forest, mask = TRUE)

mqueinnec/foster documentation built on March 28, 2021, 4:27 p.m.