Generate vegetation type map

vegTypeMapGenerator(x, ...)

# S3 method for default
vegTypeMapGenerator(x, ..., doAssertion = getOption("LandR.assertions", FALSE))

# S3 method for data.table
vegTypeMapGenerator(
  x,
  pixelGroupMap,
  vegLeadingProportion = 0.8,
  mixedType = 2,
  sppEquiv = NULL,
  sppEquivCol,
  colors,
  pixelGroupColName = "pixelGroup",
  doAssertion = getOption("LandR.assertions", TRUE),
  ...
)

Arguments

x

Either a cohortData object or a speciesCover RasterStack/SpatRaster

...

Additional arguments.

doAssertion

A logical indicating whether some internal tests should be run to ensure the function is running correctly. Default: getOption("LandR.assertions", TRUE).

pixelGroupMap

A RasterLayer with pixel values equal to a pixel group number that corresponds exactly to pixelGroup column in cohortData.

vegLeadingProportion

Numeric between 0-1, determining the relative biomass threshold a species needs to pass to be considered "leading".

mixedType

An integer defining whether mixed stands are: not differentiated (0), any kind of species admixture (1), or deciduous mixed with conifer (2; default).

sppEquiv

table with species name equivalencies between the kNN and final naming formats. See data("sppEquivalencies_CA", "LandR"). For functions that have mixedType, this only necessary if mixedType == 2. If not provided and mixedType == 2, will attempt to use data("sppEquivalencies_CA", "LandR").

sppEquivCol

the column name to use from sppEquiv. For functions that have mixedType, only necessary if mixedType == 2. If not provided and mixedType == 2, will attempt to use "Boreal".

colors

A named vector of colour codes. The names MUST match the names of species in cohortData$speciesCode, plus an optional "Mixed" colour.

pixelGroupColName

Name of the column in pixelGroup to use.

Author

Eliot McIntire, Ceres Barros, Alex Chubaty

Examples

library(data.table)
library(terra)
x <- data.table(pixelGroup = rep(1:2, each = 2), B = c(100, 200, 20, 400),
                speciesCode = rep(c("Pice_Gla", "Popu_Tre"), 2))
pixelGroupMap <- rast(ext(0,3, 0, 3), res = 1)
pixelGroupMap[] <- sample(1:2, size = 9, replace = TRUE)
vtm <- vegTypeMapGenerator(x, pixelGroupMap = pixelGroupMap)
#> Using B to derive leading type
#> LandR::vegTypeMapGenerator: NROW(x) == 4
#> Using mixedType == 2, but no sppEquiv provided. Attempting to use data('sppEquivalencies_CA', 'LandR') and sppEquivCol == 'KNN'
#> LandR::vegTypeMapGenerator: new algo 0.00412487983703613
#> LandR::vegTypeMapGenerator: old algo 0.00592303276062012