Create the standAgeMap
raster containing age estimates for pixelCohortData
.
A separate reproducible::prepInputs()
call will source Canadian National Fire Data Base
data to update ages of recently burned pixels. To suppress this, pass NULL/NA fireURL
prepInputsStandAgeMap(
...,
ageURL = NULL,
ageFun = "raster::raster",
maskWithRTM = TRUE,
method = "bilinear",
datatype = "INT2U",
destinationPath = NULL,
filename2 = NULL,
firePerimeters = NULL,
fireURL = paste0("https://cwfis.cfs.nrcan.gc.ca/downloads/nfdb/",
"fire_poly/current_version/NFDB_poly.zip"),
fireFun = "terra::vect",
fireField = "YEAR",
rasterToMatch = NULL,
startTime
)
additional arguments passed to reproducible::prepInputs()
url where age map is downloaded
passed to 'fun' arg of reproducible::prepInputs()
of stand age map
passed to reproducible::prepInputs()
of stand age map
passed to reproducible::prepInputs()
of stand age map
passed to reproducible::prepInputs()
of stand age map
path to data directory where objects will be downloaded or saved to
passed to reproducible::prepInputs()
of stand age map
fire raster layer fire year values.
url to download fire polygons used to update age map. If NULL or NA age
imputation is bypassed. Requires passing rasterToMatch
. Only used if firePerimeters
is missing.
passed to reproducible::prepInputs()
of fire data. Only used if firePerimeters
is missing.
field used to rasterize fire polys. Only used if firePerimeters
is missing.
A RasterLayer
objects to use as the template for all subsequent
raster operations (i.e., the one used throughout the simulation).
date of the last fire year to be considered (e.g., start of fire period counting backwards). If missing, last fire year available will be used.
a raster layer stand age map corrected for fires, with an attribute vector of pixel IDs
for which ages were corrected. If no corrections were applied the attribute vector is integer(0)
.
if (FALSE) {
library(SpaDES.tools)
library(terra)
library(reproducible)
randomPoly <- vect(randomStudyArea(size = 1e7))
randomPoly
ras2match <- rast(res = 250, ext = ext(randomPoly), crs = crs(randomPoly))
ras2match <- rasterize(randomPoly, ras2match)
tempDir <- tempdir()
## NOT USING FIRE PERIMETERS TO CORRECT STAND AGE
## rasterToMatch does not need to be provided, but can be for masking/cropping.
standAge <- prepInputsStandAgeMap(destinationPath = tempDir,
rasterToMatch = ras2match,
fireURL = NA) ## or NULL
attr(standAge, "imputedPixID")
## USING FIRE PERIMETERS TO CORRECT STAND AGE
## ideally, get the firePerimenters layer first
firePerimeters <- Cache(prepInputsFireYear,
url = paste0("https://cwfis.cfs.nrcan.gc.ca/downloads",
"/nfdb/fire_poly/current_version/NFDB_poly.zip"),
destinationPath = tempDir,
rasterToMatch = ras2match)
standAge <- prepInputsStandAgeMap(destinationPath = tempDir,
firePerimeters = firePerimeters,
rasterToMatch = ras2match)
attr(standAge, "imputedPixID")
## not providing firePerimeters is still possible, but will be deprecated
## in this case 'rasterToMatch' MUST be provided
standAge <- prepInputsStandAgeMap(destinationPath = tempDir,
rasterToMatch = ras2match)
attr(standAge, "imputedPixID")
}