Create a Facet Map of a Multi-band Raster
facet_map.RdGenerates a grid of plots (a facet map), where each plot displays one layer from a multi-band raster object. This is useful for visualizing time-series imagery (e.g., monthly NDVI).
Usage
facet_map(
multi_band_raster,
plot_titles = NULL,
custom_colors = (grDevices::colorRampPalette(c("red", "yellow", "green")))(100),
output_file = "facet_map.jpg",
ncol = 4
)Arguments
- multi_band_raster
A multi-band raster object from the `terra` or `raster` package.
- plot_titles
A character vector of titles for each plot. Defaults to month names if there are 12 layers.
- custom_colors
A color palette to use for the map values.
- output_file
The path to save the final plot image.
- ncol
The number of columns in the plot grid.
Examples
if (FALSE) { # \dontrun{
library(terra)
# Create a dummy multi-band raster
r1 <- rast(nrows = 10, ncols = 10, vals = rnorm(100))
r2 <- rast(nrows = 10, ncols = 10, vals = rnorm(100))
r3 <- rast(nrows = 10, ncols = 10, vals = rnorm(100))
multi_band <- c(r1, r2, r3)
# Create a facet map
facet_map(
multi_band_raster = multi_band,
plot_titles = c("Time 1", "Time 2", "Time 3"),
output_file = "my_facet_map.jpg",
ncol = 3
)
} # }