Skip to contents

This function takes a list of raster files, creates a stack, and returns a frequency table (crosstab) of the stack. The frequency table is filtered to remove rows where the frequency is zero.

Usage

create_crosstab(land_cover, zone)

Arguments

land_cover

A list of 'SpatRaster' objects.

zone

A SpatRaster' object of planning unit/zone

Value

A data frame representing the crosstab of the input rasters.

Examples

if (FALSE) {
  # Read in the legend for raster data
  subset_legend <- LUMENSR::lc_lookup_klhk

  # Read raster files
  raster_files <- c("kalbar_LC11.tif", "kalbar_LC15.tif", "kalbar_LC20.tif") %>%
    map(LUMENSR_example) %>%
    map(rast)

  # Loop through raster files
  land_cover <- map(raster_files,
                            ~apply_lookup_table(raster_file = .x,
                                                lookup_lc = subset_legend))

  # Turn raster files into a frequency table
  crosstab_result <- create_crosstab(land_cover)
}