Make a numeric generations raster categorical
Source:R/phenology-results.R
categorize_generations_rst.Rd
Make a numeric generations raster categorical. Useful when mathematical
operations were performed with generations rasters (use
get_generations_rst(..., categorical = FALSE)
to get numeric generations
rasters).
Usage
categorize_generations_rst(
rst,
colors = barrks_colors(),
labels = barrks_labels()
)
Arguments
- rst
A numeric SpatRaster that represents bark beetle generations. Sister broods are defined by adding
0.5
to the respective generation.- colors, labels
Vectors of colors/labels starting from zero generations followed consecutively by elements for the respective generations (including sister broods).
Examples
# \donttest{
# calculate phenology with different models
p1 <- phenology('phenips-clim', barrks_data(), .quiet = TRUE)
p2 <- phenology('phenips', barrks_data(), .quiet = TRUE)
# get the generation as numerical rasters to allow mathematical operations
gens1 <- get_generations_rst(p1, categorical = FALSE)
gens2 <- get_generations_rst(p2, categorical = FALSE)
# calculate the maximum generations from the 2 models
gens_max <- max(gens1, gens2)
# categorize the results
gens_max_cat <- categorize_generations_rst(gens_max)
# plot the categorized raster
terra::plot(gens_max_cat)
# plot the uncategorized raster
terra::plot(gens_max)
# }