Calculate land cover frequency for multiple raster layers
calc_lc_freq.Rd
This function takes multiple raster layers as input and returns a frequency table for each layer, sorted by the count of the last raster layer in descending order. An input of a terra's rast object is allowed.
Examples
if (FALSE) {
library(tidyverse)
# Create a vector of raster file names
lc_maps <- c("kalbar_LC11.tif", "kalbar_LC20.tif") %>%
# Apply LUMENSR_example function to each file in the vector
map(~ LUMENSR_example(.x)) %>%
# Convert each file to a raster object
map(~ terra::rast(.x)) %>%
# Add a legend to each raster object using a provided lookup table
map(~ add_legend_to_categorical_raster(raster_file = .x, lookup_table = lc_lookup_klhk))
# Calculate the frequency table for each raster object in the list
freq_table <- calc_lc_freq(lc_maps)
# Print the resulting frequency table
print(freq_table)
}