mf_raster: Plot a raster

View source: R/mf_raster.R

mf_rasterR Documentation

Plot a raster

Description

Plot a raster object (SpatRaster from terra).

Usage

mf_raster(
  x,
  pal,
  expandBB = rep(0, 4),
  alpha = 1,
  rev = FALSE,
  leg_pos = "right",
  leg_title = names(x),
  leg_title_cex = 0.8,
  leg_val_cex = 0.6,
  leg_val_rnd = 2,
  leg_no_data = "No data",
  leg_frame = FALSE,
  leg_frame_border = getOption("mapsf.fg"),
  leg_horiz = FALSE,
  leg_adj = c(0, 0),
  leg_fg = getOption("mapsf.fg"),
  leg_bg = getOption("mapsf.bg"),
  leg_size = 1,
  add = FALSE,
  ...
)

Arguments

x

a SpatRaster

pal

a set of colors or a palette name (from hcl.colors)

expandBB

fractional values to expand the bounding box with, in each direction (bottom, left, top, right)

alpha

if pal is a hcl.colors palette name, the alpha-transparency level in the range [0,1]

rev

if pal is a hcl.colors palette name, whether the ordering of the colors should be reversed (TRUE) or not (FALSE)

leg_pos

position of the legend, one of 'topleft', 'top','topright', 'right', 'bottomright', 'bottom', 'bottomleft', 'left' or a vector of two coordinates in map units (c(x, y)). If leg_pos = NA then the legend is not plotted. If leg_pos = 'interactive' click onthe map to choose the legend position.

leg_title

legend title

leg_title_cex

size of the legend title

leg_val_cex

size of the values in the legend

leg_val_rnd

number of decimal places of the values in the legend

leg_no_data

label for missing values

leg_frame

whether to add a frame to the legend (TRUE) or not (FALSE)

leg_frame_border

border color of the legend frame

leg_horiz

display the legend horizontally

leg_adj

adjust the postion of the legend in x and y directions

leg_fg

color of the legend foreground

leg_bg

color of the legend backgournd

leg_size

size of the legend; 2 means two times bigger

add

whether to add the layer to an existing plot (TRUE) or not (FALSE)

...

bgalpha, smooth, maxcell or other arguments passed to be passed to plotRGB or plot

Value

No return value, a map is displayed.

Examples

if (require("terra")) {
  r <- rast(system.file("ex/elev.tif", package = "terra"))
  mf_raster(r)
}

mapsf documentation built on Nov. 21, 2023, 5:09 p.m.