Spatial ggplot2 layer for SpatRaster objects
This is intended for use with RGB(A) rasters (e.g., georeferenced imagery or photos). To work with bands as if they were columns, use df_spatial
and geom_raster . data
An object of class StatSpatialRaster
(inherits from Stat
, ggproto
, gg
) of length 3.
An object of class StatSpatRaster
(inherits from StatSpatialRaster
, Stat
, ggproto
, gg
) of length 3.
An object of class StatSpatRasterDf
(inherits from Stat
, ggproto
, gg
) of length 5.
An object of class GeomSpatRaster
(inherits from Geom
, ggproto
, gg
) of length 5.
## S3 method for class 'SpatRaster' layer_spatial( data, mapping = NULL, interpolate = NULL, is_annotation = FALSE, lazy = FALSE, dpi = 150, ... ) ## S3 method for class 'SpatRaster' annotation_spatial(data, mapping = NULL, interpolate = NULL, ...) StatSpatRaster StatSpatRasterAnnotation StatSpatRasterDf GeomSpatRaster
data
: A SpatRaster object created with terra::rast()
.mapping
: Currently, only RGB or RGBA rasters are supported. In the future, one may be able to map specific bands to the fill and alpha aesthetics.interpolate
: Interpolate resampling for rendered raster imageis_annotation
: Lets raster exist without modifying scaleslazy
: Delay projection and resample of raster until the plot is being rendereddpi
: if lazy = TRUE, the dpi to which the raster should be resampled...
: Passed to other methodsA ggplot2 layer
library(ggplot2) load_longlake_data( which = c( "longlake_osm", "longlake_depth_raster" ), raster_format = "terra" ) ggplot() + layer_spatial(longlake_osm) ggplot() + layer_spatial(longlake_depth_raster) + scale_fill_continuous( na.value = NA, type = "viridis" )
Useful links