Description Usage Arguments Details Value See Also Examples
This function creates a spatial object (raster or vector) defining the area of interest, by taking a bounding box or
a spatial object, or unioning the input spatial objects if more than one are provided.
When msk
is a list of rasters, extent is set equal to their combined extent (union) and resolution
to the finest resolution among them.
1 |
msk |
a character (path to raster or vector file), or a bounding box as numeric (xmin,xmax,ymin,ymax),
or one or more (as list of) rasters of class "RasterLayer", or a single object of class "sf" or "SpatialPolygonsDataFrame".
The reference data (raster or vector) to be used as mask. All model outputs will have the same extent (outline) as this object.
All locations with no data (i.e. NA) cells in |
mskSub |
vector of values, for raster data only. The subset values from |
xy |
logical. Should return a two column matrix of x and y coordinates of cells centre (raster data) or the IDs of features? Defaults to FALSE, returning an object of class RasterLayer or sf. |
bbox |
numeric of four elements, the coordinates defining a rectangle (bounding box) to limit the area of interest. Must be ordered as xmin, xmax, ymin, ymax. Coordinates must be in the same reference system as spatial data. |
If rasters are used, 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.
An object of class RasterLayer or sf, or a matrix of coordinates of mask cells (raster only). In the former case, valid cells
(i.e. the area of interest) will have value 1, NA
otherwise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Make a mask from a group of input layers:
list2env(ConwyData, environment())
network <- LandUseChange
spatialData <- c(ConwyLU, ConwySlope, ConwyStatus)
m <- aoi(spatialData)
m
## Plot mask
library(raster)
m <- aoi(ConwyLU)
plot(m)
## Make mask from a subset of values and plot
m <- aoi(ConwyLU, mskSub=c(2,3))
plot(m)
## Return coordinates of valid mask locations
coord <- aoi(ConwyLU, xy=TRUE)
head(coord)
## Using a bounding box
aoi(ConwyLU, bbox=c(270000, 284950, 347000, 365000))
## For vectorial spatial data. Note xy=TRUE shall return the features IDs
Conwy = sf::st_read(system.file("extdata", "Conwy.shp", package = "bnspatial"))
aoi(Conwy, bbox=c(270000, 284950, 347000, 365000))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.