plot: Plot raster objects using 'ggplot'

plotR Documentation

Plot raster objects using ggplot

Description

This function plots objects of class SpatRaster, RasterLayer, RasterBrick or RasterStack as ggplot2. It is used internally by basemap* functions that return ggplot plots.

Usage

gg_raster(r, r_type = "RGB", gglayer = F, ...)

Arguments

r

raster of class SpatRaster, RasterLayer, RasterBrick or RasterStack.

r_type

character, either "gradient" or "discrete".

gglayer

logical, if FALSE (default), a ggplot2 plot is returned, if TRUE, a ggplot2 layer is returned.

...

additional arguments, including

  • maxpixels, numeric, maximum number of pixels to be plotted (default: 500000)

  • alpha, numeric between 0 and 1, alpha value of the plotted data (transparency).

  • maxColorValue, numeric, the value to use as colour maximum.

Value

A ggplot2 object

Examples

library(basemaps)

# example extent
data(ext)

## Not run: 
# raster object: Brick
map <- basemap_raster(ext)

# plotting RasterBrick
gg_raster(map, r_type = "RGB")

## End(Not run)


basemaps documentation built on Sept. 27, 2022, 1:10 a.m.