static_map: Produce a static map of establishment likelihood

View source: R/static_map.R

static_mapR Documentation

Produce a static map of establishment likelihood

Description

Produce a static map of establishment likelihood, with OpenStreetMap base layer.

Usage

static_map(
  ras,
  xlim,
  ylim,
  subset_layers,
  layer_names,
  legend_title,
  set_value_range,
  scale_type = "none",
  basemap_mode = c("osm", "boundaries"),
  transparency = 0.7,
  colramp_entire_range = TRUE,
  surveillance_locs,
  shape = 21,
  pt_col = "red",
  aggregate_raster,
  nrow,
  height,
  outfile
)

Arguments

ras

A Raster* object or file path to a (potentially multiband) raster file.

xlim

Numeric vector. The longitudinal extent of the area to plot, in WGS84 coordinates.

ylim

Numeric vector. The latitudinal extent of the area to plot, in WGS84 coordinates.

subset_layers

Vector. A vector of layer names or numeric positions to be included in plot. Only relevant if loading a RasterStack or RasterBrick. If missing all layers are included.

layer_names

Character vector. A vector of panel titles (only relevant if ras is a stack). If not provided, names from ras will be used. If provided, length must equal raster::nlayers(ras), or match length(subset_layers).

legend_title

Character. Legend title.

set_value_range

A numeric vector containing an upper and lower bound value (in units of raster). Values outside this range (including values falling on the boundaries) will be masked.

scale_type

Character. One of:

  • "none" (raw data, no rescaling);

  • "log10";

  • "max normalize" (proportional to maximum value);

  • "minmax normalize" (rescale values to be between zero and 1 based on min and max); or

  • "discrete". Note that if "log10" is used 0 or 1 values. must be masked (using set_value_range) or rescaled outside of this function.

basemap_mode

Either 'boundaries' or 'osm' (i.e., OpenStreetMap), defining whether OpenStreetMap imagery should be used for static map basemaps, or simple administrative boundaries. Default is 'osm'.

transparency

Numeric. Transparency of raster, between 0-1.

colramp_entire_range

Logical. Whether to set colour ramp limits based on national risk range (TRUE) or by risk range present in region specified by xlim and ylim.

surveillance_locs

A spatial object or a path to a .csv file containing columns named "Latitude" and "Longitude".

shape

shape(s) to use for surveillance locations. Default is 21. If you have multiple bands, and you'd like to use different symbols on each panel, specify a vector of shapes. (e.g. c(NA, 21,21,21) will not include shapes on the first panel, but will on the rest

pt_col

Character. The plotting colour for surveillance points.

aggregate_raster

NULL or a list containing the aggregation factor (i.e. number of raster cells to aggregate) and the aggregation function e.g. list(10, sum).

nrow

For multipanel plots, an optional numeric value defining the number of rows of panels.

height

height of plot in inches (will be rendered at 300 dpi). If not defined will use size of current graphic device. Width will be determined automatically, based on the aspect ratio given by the plotting extent.

outfile

Character. File path to save map.

Details

This function relies on the OpenStreetMap package to obtain base layer tiles. This in turn requires Java to be installed, and linking R with Java can sometimes prove challenging. On macOS, Java errors can often be resolved by entering sudo R CMD javareconf in a terminal ( which updates R's Java configuration variables). On Windows, ensure that the Java architecture (32-bit/64-bit) matches that of R. Additionally, some Java errors arise when using RStudio but not when using R.

Value

If outfile is provided, a map is saved to that file. Otherwise, a tmap object is returned to R.


jscamac/edmaps documentation built on June 11, 2022, 1:26 a.m.