datacarpentry / r-raster-vector-geospatial

Introduction to Geospatial Raster and Vector Data with R
https://datacarpentry.org/r-raster-vector-geospatial
Other
112 stars 107 forks source link

Consider using tidyterra for plotting #434

Open AndyBunn opened 3 months ago

AndyBunn commented 3 months ago

How could the content be improved?

The tidyterra library has a nice geom for SpatRaster objects. E.g.,

library(tidyterra)
DSM_HARV <-
  rast("/data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_dsmCrop.tif")
ggplot() + geom_spatraster(data = DSM_HARV , aes(fill = HARV_dsmCrop)) +
  scale_fill_viridis_c()

This would keep students from having to convert to data.frame or tibble for geom_raster

jebyrnes commented 3 months ago

Agree. I know it’s another dependency, but it takes away the need to continually turn rast objects into data frames, which confuses learners, and plays nice with geom_sf() for overlays.