updateCaribou: Update an existing CaribouHabitat Object

updateCaribouR Documentation

Update an existing CaribouHabitat Object

Description

Update a CaribouHabitat object in order to avoid reprocessing parts of the data that have not changed. New data is supplied as a named list and the object is updated depending on the elements provided in the list.

Usage

updateCaribou(CarHab, newData, ...)

## S4 method for signature 'CaribouHabitat,missing'
updateCaribou(CarHab, coefTable = coefTableHR, doScale = FALSE)

## S4 method for signature 'CaribouHabitat,list'
updateCaribou(
  CarHab,
  newData,
  resultsOnly = FALSE,
  coefTable = coefTableHR,
  doScale = FALSE
)

Arguments

CarHab

CaribouHabitat object

newData

a named list of objects to be used to update CarHab. Potential names are: landCover, natDist, anthroDist, and linFeat.

...

other arguments passed to methods. Not currently used.

coefTable

data.frame. Optional table of coefficients to be used in the model. Must match the format and naming of coefTableHR

doScale

logical. FALSE by default. Set to TRUE only if you have supplied coefficients that were trained on standardized data which will cause the input data to be scaled.

resultsOnly

logical. If FALSE the whole CaribouHabitat object is returned. If TRUE then only the habitatUse RasterStack is returned.

Details

If newData contains only linFeat then only linear features will be updated.

If newData contains landCover the landCover in the CaribouHabitat object will be replaced and new projections made for the whole landscape. If natDist or anthroDist are not provided then the data stored in the CaribouHabitat object is reused.

Value

If resultsOnly is FALSE an updated CaribouHabitat object. If resultsOnly is TRUE a RasterStack with a layer for each season.

See Also

Caribou habitat functions: CaribouHabitat-class, calcBinaryUse(), caribouHabitat(), coefTableHR, coefTableStd, fnlcToResType, loadSpatialInputs(), plcToResType, rasterizeLineDensity(), reclassPLC(), resTypeCode, results(), rfuToResType, threshTable

Examples

# 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)))

# calculate relative probability of use
res <- caribouHabitat(landCover = lc,
               linFeat = lf,
               esker = esk,
               natDist = nd,
               anthroDist = ad,
               projectPoly = projPol,
               caribouRange = "Nipigon",
               winArea = 1000 #leave as default NULL except for small examples
)

# new linear features
lf2 <- sf::st_as_sf(sf::st_sfc(list(sf::st_linestring(matrix(c(0, 0, 25000, 25000),
                                                             ncol = 2, byrow = TRUE)),
                                    sf::st_linestring(matrix(c(0, 20000, 20000, 25000),
                                                             ncol = 2, byrow = TRUE)),
                                    sf::st_linestring(matrix(c(10000, 0, 20000, 20000),
                                                             ncol = 2, byrow = TRUE))),
                              crs = 5070))


res2 <- updateCaribou(res, newData = list(linFeat = lf2))

# visualize the impact of new roads
plot(res, season = "Winter")
plot(res2, season = "Winter")


LandSciTech/caribouMetrics documentation built on Feb. 3, 2024, 9:41 p.m.