Skip to contents

Map a Single Raster Layer

Usage

fb_map_raster(x, ...)

Arguments

x

a SpatRaster object (package terra). A raster of one single layer

...

other parameters passed to theme()

Value

A ggplot object.

Examples

library(ggplot2)

## Load raster ----
tavg <- system.file("extdata", "annual_mean_temp.tif", package = "funbiogeo")
tavg <- terra::rast(tavg)

## Default map ----
fb_map_raster(tavg)


## Map with custom theme ----
fb_map_raster(tavg, legend.position = "bottom")


## Advanced customization ----
my_map <- fb_map_raster(tavg) + 
  scale_fill_distiller("Temperature", palette = "Spectral") +
  theme(legend.position = "bottom") + 
  ggtitle("Mean annual temperature in Western Europe")

my_map


## Map w/o annotation ----
fb_map_raster(tavg) + 
  theme_void() + 
  theme(legend.position = "none")