Create a Leaflet map with the environmental variables. This map can be explored interactively in the viewer. It's also possible to generate an html file with summary statistics of the environmental layers, together with some plot to help overview the data.

var_leaflet(
  var,
  pts = NULL,
  pal = NULL,
  layernames = NULL,
  crs = "standard",
  cluster = FALSE,
  varsummary = FALSE,
  mess = FALSE,
  mess.ref = NULL
)

# S4 method for data.frame
var_leaflet(
  var,
  pts = NULL,
  pal = NULL,
  layernames = NULL,
  crs = "standard",
  cluster = FALSE,
  varsummary = FALSE,
  mess = FALSE,
  mess.ref = NULL
)

# S4 method for Raster
var_leaflet(
  var,
  pts = NULL,
  pal = NULL,
  layernames = NULL,
  crs = "standard",
  cluster = FALSE,
  varsummary = FALSE,
  mess = FALSE,
  mess.ref = NULL
)

Arguments

var

A raster or data.frame with the environmental variables. In the case of a data.frame, the first two collumns should be, respectively, longitude and latitude.

pts

A data frame containing the presence or presence/absence points (optional). The first column should be longitude (x) and the sencond latitude (y). In the case of presence/absence data, an additional collumn should be provided, coded as 0 (absence) and 1 (presence).

pal

Character string indicating the name of the palette (see gen_pal). If not supplied, the default will be used.

layernames

An optional character vector indicating the names of the layers. This will be used in the legend. If not supplied, names will be extracted from the RasterLayer.

crs

Enables to change the default projection used in the Leaflet package. For now, not functional.

cluster

Should the points be clustered (i.e., aggregated)? Only valid if `pts` is supplied. Default is FALSE.

varsummary

If set to TRUE, an RMarkdown file will be generated with a series of summary statistics for the variables. Points should also be supplied in that case (with a column for presence/absence). This is still quite experimental. Default is FALSE.

mess

If set to TRUE, an aditional layer is included with the MESS map, using as a reference the environmental data in the presence/absence points (i.e. the data that will be used to train the model). In the case you are plotting future environmental data, you should supply a raster* in the mess.ref argument. Note: setting MESS to TRUE can make the plotting slower.

mess.ref

If plotting future layers and MESS = TRUE, a Raster* with the same names of the provided layers from where the reference points will be extracted.

Value

A Leaflet map and optionally an .html file with summary statistics.

Functions

  • var_leaflet,data.frame-method: Method for data frames

  • var_leaflet,Raster-method: Method for raster

Examples

library(sdmvis) data("pa_data") data("env_data") var_leaflet(var = env_data, pts = pa_data, mess = FALSE)
#> Warning: Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
#> Warning: Discarded datum World Geodetic System 1984 in Proj4 definition
#> Error in .local(.Object, ...):