Load spatial input data from file and then align the inputs to the
projectPoly
and refRast
. Inputs can be file names or spatial objects.
loadSpatialInputs(
projectPoly,
refRast,
inputsList,
convertToRast = NULL,
convertToRastDens = NULL,
altTemplate = NULL,
useTemplate = NULL,
reclassOptions = NULL,
bufferWidth = NULL,
ptDensity = 1,
rastOut = "terra"
)
character or sf. A polygon delineating the study area.
character or raster. A raster which will be used as the
template that all other rasters must align to (but see alttemplate
).
list. A named list of inputs that are either spatial
objects or file names of spatial objects. ".shp" is the only extension
accepted for vector data and all other extensions will be passed to
terra::rast()
. If an element is a list these are assumed to be linear features
and they are combined.
character. Optional. Names of elements of inputsList
that should be converted to raster after loading.
character. Optional. Names of elements of
inputsList
that should be converted to raster line density after loading.
raster. Optional template raster for raster inputs that
can have a different resolution from the refRast
.
character. Optional. Names of elements of inputsList
that use altTemplate
.
list. An optional named list containing a function, a
list where the first element is a function that takes the corresponding
inputsList
element as its first argument and the subsequent elements are
named arguments for that function, or a matrix that will be passed to
terra::classify()
.
numeric. The width of a moving window that will be applied
to the data. If it is supplied a buffer of 3*bufferWidth
around the
projectPoly
is used so that rasters will be cropped to a larger area.
This can be used to avoid edge effects in moving window calculations
number. Only used if an element of inputsList
is a list
that contains a mixture of rasters and lines and is included in
convertToRast. See rasterizeLineDensity()
.
character. The format that rasters should be output with. "raster" for RasterLayers and "terra" for SpatRasters. The default is "terra".
A named list with aligned spatial data components
Caribou habitat functions:
CaribouHabitat-class
,
calcBinaryUse()
,
caribouHabitat()
,
coefTableHR
,
coefTableStd
,
fnlcToResType
,
plcToResType
,
rasterizeLineDensity()
,
reclassPLC()
,
resTypeCode
,
results()
,
rfuToResType
,
threshTable
,
updateCaribou()
# create example rasters
lc <- terra::rast(xmin = 0, xmax = 25000, ymin = 0, ymax = 25000,
resolution = 250, crs = "EPSG:5070")
lc[] <- 0
nd <- lc
nd[1:30, 1:30] <- 1
ad <- lc
ad[30:50, 3:50] <- 1
lc[] <- 1
lc[70:100, 70:100] <- 2
# create sf objects
lf <- sf::st_as_sf(sf::st_sfc(list(sf::st_linestring(matrix(c(0, 0, 10000, 10000),
ncol = 2, byrow = TRUE))),
crs = 5070))
esk <- sf::st_as_sf(sf::st_sfc(list(sf::st_linestring(matrix(c(0, 10000, 10000, 0),
ncol = 2, byrow = TRUE))),
crs = 5070))
projPol <- sf::st_sf(sf::st_as_sfc(sf::st_bbox(ad)))
# prepare data
res <- loadSpatialInputs(projectPoly = projPol, refRast = lc,
inputsList = list(esker = esk, linFeat = lf, natDist = nd,
anthroDist = ad),
convertToRast = c("esker", "linFeat"))
#> cropping esker to extent of projectPoly
#> cropping linFeat to extent of projectPoly