Skip to contents

A ggplot2 discrete fill scale that applies the official MapBiomas Fuego Peru (Collection 1) color palette for a given sub-product to a classified SpatRaster (as a factor), for use with tidyterra::geom_spatraster().

Usage

scale_fill_mapbiomas_peru_fire_d(
  product,
  ...,
  lang = c("en", "es"),
  na.translate = FALSE
)

Arguments

product

Character. One of the products listed in get_mapbiomas_peru_fire_products.

...

Additional arguments passed to scale_fill_manual.

lang

Character. Language for the legend labels, either "en" (default) or "es".

na.translate

Logical. Should NA values be displayed in the legend? Default is FALSE.

Value

A ggplot2 discrete scale object.

Examples

if (FALSE) { # \dontrun{
library(geoidep)
library(ggplot2)
library(tidyterra)

lima <- get_departaments("LIMA", show_progress = FALSE)

# Frecuencia de área quemada
freq <- get_mapbiomas_peru_fire(
  product = "frequency_burned",
  year = 2024,
  crop_to = lima
)

ggplot() +
  geom_spatraster(data = as.factor(freq)) +
  scale_fill_mapbiomas_peru_fire_d("frequency_burned", lang = "es") +
  theme_minimal() +
  labs(fill = "N° de quemas", title = "Frecuencia de área quemada 2013-2024")

# Año del último fuego
last_fire <- get_mapbiomas_peru_fire(
  product = "year_last_fire",
  year = 2024,
  crop_to = lima
)

ggplot() +
  geom_spatraster(data = as.factor(last_fire)) +
  scale_fill_mapbiomas_peru_fire_d("year_last_fire", lang = "es") +
  theme_minimal() +
  labs(fill = "Año", title = "Año del último fuego")
} # }