This function plots objects of class SpatRaster
, RasterLayer
, RasterBrick
or RasterStack
as ggplot2
. It is used internally by basemap*
functions that return ggplot
plots.
Arguments
- r
raster of class
SpatRaster
,RasterLayer
,RasterBrick
orRasterStack
.- r_type
character, either
"gradient"
or"discrete"
.- gglayer
logical, if
FALSE
(default), aggplot2
plot is returned, ifTRUE
, aggplot2
layer is returned.- ...
additional arguments, including
maxpixels
, numeric, maximum number of pixels to be plotted (default: number of pixels in r). Use a value lower then ncell(r) to lower resolution for faster plotting.alpha
, numeric between 0 and 1, alpha value of the plotted data (transparency).maxColorValue
, numeric, the value to use as colour maximum.interpolate
, logical, whether to smooth the plot (default isTRUE
).
Examples
library(basemaps)
# example extent
data(ext)
if (FALSE) {
# raster object: Brick
map <- basemap_raster(ext)
# plotting RasterBrick
gg_raster(map, r_type = "RGB")
}