Produces interactive html maps of extrapolation values in the prediction area. The function relies on the leaflet package (Cheng et al. 2018), and thus requires an internet connection (i.e. will not work offline).

map_extrapolation(
  map.type = NULL,
  extrapolation.object = NULL,
  base.layer = "ocean",
  sightings = NULL,
  tracks = NULL,
  verbose = TRUE
)

Arguments

map.type

Character string. Type of map to be returned. Either extrapolation for an extrapolation map, mic for a map of the most influential covariates, or nearby for a map of the percentage of data nearby.

extrapolation.object

List object as returned by compute_extrapolation or compute_nearby.

base.layer

Base layer used for mapping. The default is ocean, which uses the ESRI.OceanBasemap. Use world for ESRI.WorldImagery and gray for ESRI.WorldGrayCanvas. Available map tiles can be viewed at https://leaflet-extras.github.io/leaflet-providers/preview/.

sightings

Species observations (optional). Can be supplied as a matrix of coordinates, a data.frame, a SpatialPoints object or a SpatialPointsDataFrame object. Circle markers will be proportional to group size if the data contain a column labelled size.

tracks

Survey tracks (optional). Can be supplied as a matrix of coordinates, a data.frame, a SpatialLines object or a SpatialLinesDataFrame object. A TransectID field is required for matrix or data.frame inputs.

verbose

Logical. Show or hide possible warnings and messages.

Value

An interactive html map.

References

Bouchet PJ, Miller DL, Roberts JJ, Mannocci L, Harris CM and Thomas L (2019). From here and now to there and then: Practical recommendations for extrapolating cetacean density surface models to novel conditions. CREEM Technical Report 2019-01, 59 p. https://research-repository.st-andrews.ac.uk/handle/10023/18509

Cheng J, Karambelkar B, Xie Y (2018). leaflet: Create Interactive Web Maps with the JavaScript 'Leaflet' Library. R package version 2.0.2. https://CRAN.R-project.org/package=leaflet

Examples

library(dsmextra) # Load the Mid-Atlantic sperm whale data (see ?spermwhales) data(spermwhales) # Extract the data segs <- spermwhales$segs predgrid <- spermwhales$predgrid # Define relevant coordinate system my_crs <- sp::CRS("+proj=aea +lat_1=38 +lat_2=30 +lat_0=34 +lon_0=-73 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0") # Define covariates of interest my_cov <- c("Depth", "DistToCAS", "SST", "EKE", "NPP") # Assess extrapolation in the multivariate space defined by five covariates spermw.extrapolation <- compute_extrapolation(samples = segs, covariate.names = c("Depth", "DistToCAS", "SST", "EKE", "NPP"), prediction.grid = predgrid, coordinate.system = my_crs)
#> Computing ...
#> Done!
# Assess the percentage of data nearby spermw.nearby <- compute_nearby(samples = segs, prediction.grid = predgrid, coordinate.system = my_crs, covariate.names = my_cov, nearby = 1)
#> Preprocessing data ...
#> Calculating distances ....
#> Calculating the geometric variance...
#> Calculating cumulative frequencies ...
#> Finishing up ...
#> Done!
# Generate maps map_extrapolation(map.type = "extrapolation", extrapolation.object = spermw.extrapolation)
#> Warning: map_extrapolation relies on the leaflet package, which is built around a Web Mercator projection (EPSG:3857), and therefore requires rasters to be reprojected for plotting. As a result, minor discrepancies may occur between the interactive maps shown in the viewer, and the underlying raw data. The latter can be accessed directly from extrapolation object returned by <compute_extrapolation> and visualised using alternative packages such as ggplot2.
map_extrapolation(map.type = "mic", extrapolation.object = spermw.extrapolation)
#> Warning: map_extrapolation relies on the leaflet package, which is built around a Web Mercator projection (EPSG:3857), and therefore requires rasters to be reprojected for plotting. As a result, minor discrepancies may occur between the interactive maps shown in the viewer, and the underlying raw data. The latter can be accessed directly from extrapolation object returned by <compute_extrapolation> and visualised using alternative packages such as ggplot2.
map_extrapolation(map.type = "nearby", extrapolation.object = spermw.nearby)
#> Warning: map_extrapolation relies on the leaflet package, which is built around a Web Mercator projection (EPSG:3857), and therefore requires rasters to be reprojected for plotting. As a result, minor discrepancies may occur between the interactive maps shown in the viewer, and the underlying raw data. The latter can be accessed directly from extrapolation object returned by <compute_extrapolation> and visualised using alternative packages such as ggplot2.