This will search around the pixels on rstLCC that have classesToReplace, and search in iteratively increasing radii outwards for other Land Cover Classes than the those indicated in classesToReplace. This will constrain It will then take the cohorts that were in pixels with classesToReplace and assign them new values in the output object. This function will also check that it must be an ecoregionCode that already exists in cohortData, i.e., not create new ecoregionCode values. See Details.

convertUnwantedLCC(
  classesToReplace = 34:36,
  rstLCC,
  availableERC_by_Sp,
  theUnwantedPixels,
  ecoregionGroupVec,
  speciesEcoregion,
  pixelClassesToReplace,
  doAssertion = getOption("LandR.assertions", TRUE)
)

Arguments

classesToReplace

Integer vector of classes that are are to be replaced, e.g., 34, 35, 36 on LCC2005, which are burned young, burned 10 year, and cities.

rstLCC

LCC raster, e.g., LCC2005

availableERC_by_Sp

A data.table or data.frame with 3 columns: speciesCode, initialEcoregionCode and pixelIndex. pixelIndex is the pixel id for each line in the data.table; speciesCode is the species name in the pixel (can have more than one species per pixel, so multiple rows per pixel); and, initialEcoregionCode is the unique codes that are "available" to be used as a replacement for classesToReplace. initialEcoregionCode must be a character vector, with one or no "_" used as a separator, with the last component being the Land Cover Class that matches classesToReplace, e.g., "242_18". If there is no "_" in this code, then the codes must match the classesToReplace exactly, e.g., "11". If pixelIndex is missing, the function will fill it with seq(ncell(rstLCC)). If speciesCode is missing, the function will replace it with a dummy value ("allSpecies").

theUnwantedPixels

An optional vector of pixel IDs that need to be changed. If not provided, then pixels to change will be taken from the match between availableERC_by_Sp and classesToReplace. Supplying this allows the user to only replace some of the pixels with a given class.

ecoregionGroupVec

Deprecated. Use availableERC_by_Sp

speciesEcoregion

Deprecated. Use availableERC_by_Sp

pixelClassesToReplace

Deprecated. Use classesToReplace

doAssertion

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

Value

A data.table with two columns, pixelIndex and ecoregionGroup. This represents the new codes to used in the pixelIndex locations. These should have no values overlapping with classesToReplace.

Details

This function is designed to be used in highly constrained situations, where it is not just replacing a Land Cover Class by a neighbouring Land Cover Class. But it can be used for the simpler cases of simply replacing a Land Cover Class.