Discrete fill scale for MapBiomas Peru LULC classes
Source:R/scale_fill_mapbiomas_peru_lulc_d.R
scale_fill_mapbiomas_peru_lulc_d.RdA ggplot2 discrete fill scale that applies the official MapBiomas
Peru Collection 3 color palette to a classified SpatRaster (as a
factor), for use with tidyterra::geom_spatraster().
Usage
scale_fill_mapbiomas_peru_lulc_d(
...,
lang = c("en", "es"),
na.translate = FALSE
)Arguments
- ...
Additional arguments passed to
scale_fill_manual.- lang
Character. Language for the legend labels, either
"en"(default) or"es".- na.translate
Logical. Should
NAvalues be displayed in the legend? Default isFALSE.
Examples
if (FALSE) { # \dontrun{
library(geoidep)
library(ggplot2)
library(tidyterra)
lima <- get_departaments("LIMA")
lulc_2024 <- get_mapbiomas_peru_lulc(year = 2024, crop_to = lima)
ggplot() +
geom_spatraster(data = as.factor(lulc_2024)) +
scale_fill_mapbiomas_peru_lulc_d(lang = "es") +
theme_minimal() +
labs(fill = "Cobertura/Uso", title = "MapBiomas Perú 2024")
} # }