replaceAgeInFires: Replace stand age with time since last fire

replaceAgeInFiresR Documentation

Replace stand age with time since last fire

Description

Replace stand age with time since last fire

Usage

replaceAgeInFires(standAgeMap, firePerimeters, startTime)

Arguments

standAgeMap

a raster layer stand age map

firePerimeters

the earliest fire date to allow

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.

Value

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

Examples

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

standAge <- prepInputsStandAgeMap(destinationPath = tempDir,
                                  rasterToMatch = ras2match,
                                  fireURL = NA)   ## or NULL
attr(standAge, "imputedPixID")

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 <- replaceAgeInFires(standAge, firePerimeters)
attr(standAge, "imputedPixID")

## End(Not run)

PredictiveEcology/LandR documentation built on June 7, 2024, 4:16 p.m.