prepInputsStandAgeMap | R Documentation |
standAgeMap
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 |
ageURL |
url where age map is downloaded |
ageFun |
passed to 'fun' arg of |
maskWithRTM |
passed to |
method |
passed to |
datatype |
passed to |
destinationPath |
path to data directory where objects will be downloaded or saved to |
filename2 |
passed to |
firePerimeters |
fire raster layer fire year values. |
fireURL |
url to download fire polygons used to update age map. If NULL or NA age
imputation is bypassed. Requires passing |
fireFun |
passed to |
fireField |
field used to rasterize fire polys. Only used if |
rasterToMatch |
A |
startTime |
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)
.
## Not run:
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")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.