Learn R Programming

bnspatial (version 0.9)

aoi: Build area of interest (A.O.I.)

Description

This function creates a raster defining the area of interest, by unioning the input rasters or using a user defined mask. When msk is specified, resolution and extent are set equal to it, otherwise to the finest resolution among input spatial data and unioning the extents of input spatial data.

Usage

aoi(msk, mskSub = NULL, xy = FALSE)

Arguments

msk
a character (path to raster file), a raster (object of class "RasterLayer"), or a list of rasters. The reference raster(s) to be used as mask. All model outputs will have the same resolution and same extent as this raster(s). All locations with no data (i.e. NA) cells in msk will be ignored as well.
mskSub
vector. The subset values from msk which should be considered to build the area of interest. All other values will be ignored and returned as NA.
xy
logical. Should return a two column matrix of coordinates? If FALSEan object of class RasterLayer is returned.

Value

An object of class RasterLayer (default), or a matrix of coordinates of mask cells. In the former case, valid cells (i.e. the area of interest) will have value 1, NA otherwise.

Details

All model outputs will have the same resolution and same extent as inherited from msk. All locations with no data (i.e. NA) cells from msk will be ignored as well.

See Also

extractByMask

Examples

Run this code
## Make a mask from a group of input layers:
data(ConwyData)
network <- LandUseChange
spatialData <- c(currentLU, slope, status)
m <- aoi(spatialData)
m

## Plot mask
library(raster)
m <- aoi(currentLU)
plot(m)

## Make mask from a subset of values and plot
m <- aoi(currentLU, mskSub=c(2,3))
plot(m)

## Return coordinates of valid mask locations
coord <- aoi(currentLU, xy=TRUE)
head(coord)

Run the code above in your browser using DataLab