Skip to contents

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.

Usage

calc_lc_freq(raster_list)

Arguments

raster_list

list of raster layers or a single raster layer.

Value

A dataframe of frequency tables.

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)
}