plotVariable: Pretty plot of a raster file, and points if provided

Description Usage Arguments Value Author(s) Examples

View source: R/plotVariable.R

Description

Uses the leaflet library to plot a raster file, and overlayed points if the point coordinates are provided. Alternatively, it accepts a grouping vector for the points (useful to, for example, plot the presences of different species at once).

plotVariable( variable, n = 100, opacity = 0.5, begin = 0, end = 1, direction = 1, option = "D", points.x = NULL, points.y = NULL, points.groups = NULL, points.legend = "Points" )

Usage

1
2
3
plotVariable(variable, n = 100, opacity = 0.5, begin = 0, end = 1,
  direction = 1, option = "D", points.x = NULL, points.y = NULL,
  points.groups = NULL, points.legend = "Points", points.size = 10)

Arguments

variable

A raster object. It can be the subset of a brick, as in x[["variable_name"]]. If an entire brick is provided, the first layer is used by default.

n

Number of colors (integer higher than 1) to use in the color palette. Argument of the viridis function.

opacity

Transparency in the range [0, 1]. If close to 1, the underlying political map will remain hidden.

begin

Numeric in the range [0, 1], color at which the color palette starts.

end

Numeric in the range [0, 1], color at which the color palette ends

direction

Order of the colors in the color palette. Use -1 to reverse the color palette.

option

A character string indicating the colormap option to use. Four options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C"), "viridis" (or "D", the default option) and "cividis" (or "E").

points.x

Numeric vector with longitude coordinates for a set of points. Must be in the same coordinate reference ystem as x.

points.y

Numeric vector with latitude coordinates for a set of points. Must be in the same coordinate reference ystem as x, and have the same length as points.x.

points.groups

Numeric or character vector to group sets of points together. Must have the same length as points.x and points.y.

points.legend

Quoted string with the title to be used in the point legend.

points.size

Numeric, size of the points.

Value

A leaflet plot.

Author(s)

Blas Benito <blasbenito@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(virtualSpecies)
data(europe2000)
plotVariable(
 variable = europe2000[["bio1"]],
 option = "B",
 opacity = 0.7,
 points.x = virtualSpecies$observed.presence$x,
 points.y = virtualSpecies$observed.presence$y,
 points.size = 5
)

BlasBenito/SDMworkshop documentation built on March 4, 2020, 4:16 a.m.