This function classifies a given raster mosaic based on user-defined breaks.
It provides an option to calculate the frequency and area of each class, as
well as plot the classified mosaic.
Usage
mosaic_classify(mosaic, breaks, frequency = TRUE, plot = TRUE)
Arguments
- mosaic
A SpatRaster
object representing the mosaic to be classified.
- breaks
A numeric vector specifying the breakpoints for classification.
- frequency
Logical. If TRUE
, computes the class frequency and area (in hectares).
- plot
Logical. If TRUE
, plots the classified mosaic.
Value
A list with two elements:
classified
: A SpatRaster
object containing the classified mosaic.
class_freq
: A data frame containing class frequencies, areas (ha), and percentages (if frequency = TRUE
).
Examples
if(interactive()){
library(pliman)
library(terra)
# Create an example raster
r <- terra::rast(matrix(runif(100, min = 0, max = 1), nrow=10, ncol=10))
# Classify the raster
result <- mosaic_classify(r, breaks = c(0.3, 0.6))
# View results
result$classified
result$class_freq
}