mland_plot: Plots landscapes from 'MultiLand' objects

View source: R/mland_plot.R

mland_plotR Documentation

Plots landscapes from 'MultiLand' objects

Description

Returns multiple plots for each landscape generated from each point and buffer, with their radii and classes, defined by the user through a 'MultiLand' object (generated by mland()). Aesthetic parameters of plots can be customized.

Usage

mland_plot(
  x,
  raster = NULL,
  points = NULL,
  radii = NULL,
  ext_raster = NULL,
  title = "id",
  ncol = NULL,
  nrow = NULL,
  st_points = list(shape = 21, size = 2, col = "black", fill = "white", alpha = 1),
  st_buffers = list(lty = 1, lwd = 1, col = "black", alpha = 0.6),
  st_classes = list(palette = "Spectral", fill = NULL, alpha = NULL, na_value =
    c("white", 1)),
  st_ext = c("chartreuse", "firebrick1")
)

Arguments

x

An object of class 'MultiLand' generated with mland().

raster, ext_raster

Numeric. The rasterlayer to be plotted. Only one rasterlayer can be plotted at the same time, either defined in raster or ext_raster.

points

Numeric or character vector of points to be plotted. See Details.

radii

Numeric vector of radii to be plotted.

title

One of the following: "id" to plot titles as each point id (default), or "sitename" to plot titles as each pre-defined point name in x. See Details.

ncol, nrow

Number of columns and rows wherein individual plots will be arranged.

st_points

List of aesthetic arguments for points plotting: shape for points shape, size for points size, col for points border color, fill for points fill color and alpha for point transparency.

st_buffers

List of aesthetic arguments for buffers plotting: lty for buffers linetype, lwd for buffers linewidth, col for buffers border color and alpha for border transparency.

st_classes

List of aesthetic arguments for classes plotting: palette, for classes color palette, fill a vector of fill colors for classes, alpha, a vector of alpha values for classes, and na_value for the color of NA values. See Details.

st_ext

Character vector of length 2, depicting the color for the minimum and maximum values of the raster defined in ext_raster.

Details

If argument points is a character vector, mland_plot() will assume that the 'MultiLand' object inputted in argument x was created with site_ref = TRUE. This is, there is a column/attribute in points layer data with the names for each distinct point. Therefore, the inputted values in argument points will be taken as these identification names. Otherwise, if a numeric vector is inputted, these values will be taken as the automatically generated point ids (created when running mland()).

If title = "sitename", the title of individual plots will be the names of each point. For this, the names of the points in x must had been defined when the object was created with mland() (i.e. x@site_ref = TRUE). Otherwise, the argument will be ignored and the titles will be the ids of the points.

A pre-defined palette can be chosen to differentiate classes inside palette = "palette_name", inside the list defined in st_classes. Any palette from hcl.pals() can be chosen. Otherwise, the user can define specific colors for each class, inside fill. This must be a vector built with concatenated pair of values, the first value being the class (or class name, if defined during x generation), and the second value the color (either the name of the color or the hex code of the color). For example, in the case the rasterlayer has four unique values: (1, 2, 3 and 4), a plausible color definition could be the following:

 list(c(1, "green", 2, "red", 3, "black", 4, "yellow"))

Value

Multiple plots (in a unique plotting device) of landscapes around defined points, radii and classes of a MultiLand object.

Examples

## Not run: 
# Loads a 'MultiLand' object
ernesdesign <- system.file("extdata", "ernesdesign.zip", package = "multilandr")
ernesdesign <- load_mland(ernesdesign)

# Plots all points and radii
mland_plot(ernesdesign)

# Plots points 1 to 3 and only radius 3000 m
mland_plot(ernesdesign, points = 1:3, radii = 3000)

# Plot with pre-defined colors, and specifying other arguments
cols <- c(1, "forestgreen",
          2, "darkolivegreen2",
          3, "firebrick3",
          4, "goldenrod1",
          5, "deepskyblue3",
          6, "black")

mland_plot(ernesdesign, points = 9:11, radii = c(1000, 2000, 3000),
           title = "sitename", nrow = 1,
           st_points = list(shape = 9),
           st_buffers = list(lty = "dashed"),
           st_classes = list(fill = cols))

# Plot a unique landscape by calling it with its name
mland_plot(ernesdesign, points = "Peje", title = "sitename",
           st_points = list(shape = 15, col = "red"),
           st_classes = list(palette = "Hawaii"))

# Plot extra rasterlaer
mland_plot(ernesdesign, radii = 3000, ext_raster = 1, title = "sitename")

# Plot extra rasterlater with customized colors
mland_plot(ernesdesign, radii = 3000, ext_raster = 1, title = "sitename",
           st_ext = c("blue", "red"))

## End(Not run)

phuais/multilandR documentation built on Feb. 11, 2024, 9:27 p.m.