Combines a vegetation type map, a stand-age (time since fire) map and a table of rates of spread by fuel type and age class into one rate-of-spread vector, then fills the remaining flammable and non-flammable pixels with their defaults.
landmine_fire_ros(
vegTypeMap,
rstTimeSinceFire,
flammableMap,
ROSTable,
sppEquiv = NULL,
sppEquivCol = NULL,
ROSother,
knownSpecies = landmine_known_species(),
fuelTypes = NULL,
ROStype = c("default", "burny"),
ageCutoffs = c(young = 40, immature = 120),
youngFilter = c("always", "legacy"),
assertions = getOption("LandR.assertions", TRUE)
)SpatRaster of leading vegetation type, with a raster
attribute table.
SpatRaster of time since fire, or a numeric vector with
one element per pixel of vegTypeMap.
SpatRaster (or numeric vector) in which 1 marks flammable
pixels and 0 or NA marks non-flammable ones.
data.table with columns age, leading, ros. The age
values may be "mature", "immature", "young", or compound versions such as
"immature_young" where two classes share one rate.
data.table of species equivalencies, with (at least) columns
LandMine, LandWeb, and sppEquivCol. Not used with fuelTypes.
character; the sppEquiv column whose values appear as the
labels of vegTypeMap's attribute table. Not used with fuelTypes.
integer; the rate of spread for flammable pixels that are not
forested (grassland, lichen, shrub). Must lie within the range of
ROSTable$ros and within 5% of mature spruce.
named character vector mapping species codes to fuel types;
defaults to landmine_known_species(). Not used with fuelTypes.
named character vector giving the fuel type of each label of
vegTypeMap's attribute table, e.g. landmine_fuel_types() for a map of reporting
groups. When given, labels are looked up in it directly instead of being matched to
species names, and sppEquiv, sppEquivCol and knownSpecies are not used. It is an
error for a label to have no fuel type.
character; "default" leaves non-flammable pixels as NA,
"burny" gives them the young-deciduous rate so that fire can cross
discontinuous fuels.
length-2 numeric giving the young/immature and immature/mature
stand-age boundaries, in years. These are the only place the ROSTable's age
labels acquire a numeric meaning – the table itself carries no ages.
character; whether the young age class is always restricted to
the vegetation types that have a young rate ("always"), or only under the
module's original condition ("legacy", the default). See Details.
logical; run .ros_self_test() and the attribute-table check.
An integer vector of rates of spread, one element per pixel of
vegTypeMap.
youngFilter argumentThe module applied the species filter to the mature and immature classes when
!all(pixelValue %in% vegTypeIDs), but to the young class when
all(pixelValue %in% vegTypeIDs) – the opposite condition. The git history shows
this is an unfinished copy-paste: the line was introduced (ad5ddb3) as a copy of
the mature guard that still read sppEquiv["mature"] in its condition while
assigning to the young class, and the follow-up (b6d600c) repaired the subset key
but not the dropped !.
Restoring the ! is nonetheless not the fix. Because every pixelValue in the
lookup comes from the attribute table, the condition is only ever asking whether the
class has any rows at all, so the correct behaviour – for all three classes – is to
apply the filter unconditionally. That is what "always" does.
"legacy" and "always" agree except in one case: when no vegetation type present
in the landscape has a "young"-classified age row. Then "legacy" skips the filter,
every young pixel is assigned NA from an empty lookup, and that NA overwrites the
immature rate the pixel had already been given – so young stands silently fall
through to ROSother instead of their immature_young rate. With LandMine's default
ROSTable, "young" appears only for pine, so this bites on any landscape with no
pine in it, and not otherwise.
The default is "always". It makes no difference on a landscape containing pine (0 of
4,458,168 pixels differ on WesternAlbertaUpland), and prevents a pine-free study area
from being silently wrong. "legacy" remains available to reproduce older runs.
The lookup is built from which() and grep() over the attribute table, which give
row positions; those are translated into raster values via the table's own value
column. Row position and raster value coincide as LandR::vegTypeMapGenerator builds
the map, but not necessarily after a terra::writeRaster()/terra::rast() round
trip, which may return the rows in a different order. Code that reloads a saved
vegTypeMap and indexes by position – as this function's predecessor in the LandMine
module did – assigns whole species the wrong fuel type with no error. Measured on a
saved WesternAlbertaUpland vegTypeMap, that meant aspen and pine, 36% of the
landscape between them, taking each other's and softwood's rates of spread.