if (FALSE) {
library(raster)
library(terra)
r <- raster(system.file("external/test.grd", package="raster"))
s1 <- stack(r, r*2)
names(s1) <- c('meuse', 'meuse x 2')
library(ggplot2)
theme_set(theme_bw())
## With raster
gplot(s1) + geom_tile(aes(fill = value)) +
facet_wrap(~ variable) +
scale_fill_gradient(low = 'white', high = 'blue') +
coord_equal()
## With terra
s2 <- rast(s1)
gplot(s2) + geom_tile(aes(fill = value)) +
facet_wrap(~ variable) +
scale_fill_gradient(low = 'white', high = 'blue') +
coord_equal()
}
Run the code above in your browser using DataLab