plot | R Documentation |
ggplot
This function plots objects of class SpatRaster
, RasterLayer
, RasterBrick
or RasterStack
as ggplot2
. It is used internally by basemap*
functions that return ggplot
plots.
gg_raster(r, r_type = "RGB", gglayer = F, ...)
r |
raster of class |
r_type |
character, either |
gglayer |
logical, if |
... |
additional arguments, including
|
A ggplot2
object
library(basemaps)
# example extent
data(ext)
## Not run:
# terra raster object
map <- basemap_terra(ext)
# plotting raster as ggplot using the with fill aesthetic
gg_raster(map, r_type = "RGB")
# or as gg layer using the with fill aesthetic
ggplot() + gg_raster(map, r_type = "RGB", gglayer = T) + scale_fill_identity()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.