While sf objects are very easily integrated in ggplot2, raster data is a little harder. There are various ways to plot a raster object with ggplot2. A simple, adhoc approach is converting the RasterLayer object into a data.frame and then plotting it with geom_raster.
use a raster object with the same extent as the sf object
https://github.com/arc2r/book/blob/055b1a09fa2b4f7fa6d624bee5681c7445cb912f/01_Making_Maps/Static_Maps.Rmd#L107
``####
raster` objectsWhile
sf
objects are very easily integrated in ggplot2, raster data is a little harder. There are various ways to plot a raster object withggplot2
. A simple, adhoc approach is converting theRasterLayer
object into adata.frame
and then plotting it withgeom_raster
.