# NOT RUN {
# Tile of Castille and Leon (Spain) from OpenStreetMap
file_path <- system.file("extdata/cyl_tile.tif", package = "tidyterra")
library(terra)
tile <- rast(file_path)
library(ggplot2)
ggplot() +
geom_spatraster_rgb(data = tile) +
# You can use coord_sf
coord_sf(crs = 3035)
# Combine with sf objects
vect_path <- system.file("extdata/cyl.gpkg", package = "tidyterra")
cyl_sf <- sf::st_read(vect_path)
ggplot(cyl_sf) +
geom_spatraster_rgb(data = tile) +
geom_sf(aes(fill = iso2)) +
coord_sf(crs = 3857) +
scale_fill_viridis_d(alpha = 0.7)
# }
Run the code above in your browser using DataLab