# \donttest{
filepath <- system.file("extdata/volcano2.tif", package = "tidyterra")
library(terra)
volcano2_rast <- rast(filepath)
# Palette
plot(volcano2_rast, col = wiki.colors(100))
library(ggplot2)
ggplot() +
geom_spatraster(data = volcano2_rast) +
scale_fill_wiki_c()
# Binned
ggplot() +
geom_spatraster(data = volcano2_rast) +
scale_fill_wiki_b(breaks = seq(70, 200, 10))
# With discrete values
factor <- volcano2_rast %>% mutate(cats = cut(elevation,
breaks = c(100, 120, 130, 150, 170, 200),
labels = c(
"Very Low", "Low", "Average", "High",
"Very High"
)
))
ggplot() +
geom_spatraster(data = factor, aes(fill = cats)) +
scale_fill_wiki_d(na.value = "gray10")
# }
Run the code above in your browser using DataLab