Introduction to ggspatial
masterggspatial is a framework for interacting with spatial data using ggplot2 as a plotting backend. It extends ggplot2 to support spatial objects from the sf, sp, and raster packages. It leverages geom_sf() and coord_sf() for coordinate transformations, allowing you to layer spatial annotations, tiles, and rasters onto a standard ggplot object.
library(ggplot2)
library(ggspatial)
# Example workflow
ggplot() +
annotation_map_tile(zoomin = -1) +
annotation_spatial(your_sf_object, size = 2, col = "black") +
layer_spatial(your_raster_object, aes(colour = after_stat(band1))) +
annotation_scale(location = "tl") +
annotation_north_arrow(location = "br", which_north = "true")