rgbPlot: Plot a map with leverage values as RGB colours. The leverage...

View source: R/rgbPlot.R

rgbPlotR Documentation

Plot a map with leverage values as RGB colours. The leverage values outputted from SDM profilinf for unsampled cells for three leverage categories are mapped on to the RGB values

Description

Plot a map with leverage values as RGB colours. The leverage values outputted from SDM profilinf for unsampled cells for three leverage categories are mapped on to the RGB values

Usage

rgbPlot(
  profile,
  origSDM,
  dual_col = "green",
  absence_col = "red",
  save_plots = FALSE
)

Arguments

profile

the output from sdmProfiling

origSDM

a raster file of the probability of occurrences of the original SDM built using the sampled cells (i.e. those in 'sampledCoords')

dual_col

The colour (either "green" (default) or "purple" for the dual-leverage (top-right) corner

absence_col

The colour (either "red" (default) or "blue" for the absence-leverage (bottom-right) corner

save_plots

TRUE or FALSE whether to save the final plots to a TableGrob object

Value

a tableGrob of two raster plots: 1) a legend plot that includes the profiling values as well as a background of the RGB colours 2) a raster of the RGB colours for the profilied cells

Optionally, if save_plots = TRUE will output the tableGrob.

Author(s)

Charlie Marsh (charlie.marsh@mailbox.org) & Yoni Gavish

Examples

set.seed(111)
envSet <- create_env_nsets(cellDims = c(25, 25),
                           sets     = c(2, 2, 2, 1),
                           model    = "Sph",
                           psill    = 1.5,
                           dep1     = 1,
                           rangeFun = function() exp(runif(1, 1, 6)),
                           propSamp = 0.1)

### generate a virtual species from the variables
sp <- create_sp(envStack = envSet,
                spFun    = "x[1] * x[3] * x[5]",
                spModel  = "Sph",
                spPsill  = 1,
                spRange  = 500,
                propSamp = 0.5,
                prev     = 0.25)

### an initial 'sample' of the species (assuming perfect detection)
sampPts <- data.frame(sampleRandom(sp$presence, 15, na.rm = TRUE, xy = TRUE))

### a formula to fit to random forest (additive for all vars + quadratics)
form <- paste0("presence ~ ", paste(names(envSet), collapse = " + "), "+ I(",
               paste(names(envSet), collapse = " ^ 2) + I("), " ^ 2)")

### run the initial model
spMod <- sdmModelling(samples = sampPts,
                      envStack = envSet,
                      modFormula = form,
                      ntrees = 500,
                      plot = FALSE)

### the full set of unsampled points to profile
unsampPts <- expand.grid(x = 1:25, y = 1:25)
unsampPts <- unsampPts[!paste(unsampPts$x, unsampPts$y) %in%
                         paste(sampPts$x, sampPts$y), ]

profile <- sdmProfiling(unsampledCoords = unsampPts,
                        sampledCoords   = sampPts,
                        origSDM         = spMod,
                        envStack        = envSet,
                        sdmFun          = "sdmModelling",
                        sdmFunArgs      = list(samples    = NULL,
                                               envStack   = envSet,
                                               modFormula = form,
                                               ntrees     = 100),
                        parallel = FALSE)

### simple plot of points
rgbPlot(profile = profile, origSDM = spMod)

### you can specify how to map the red-green-blue colours
### the top right (dual_col) can be either green (default) or purple
rgbPlot(profile = profile, origSDM = spMod,
        dual_col = "purple", absence_col = "red")

### the bottom right (absence_col) can be either red (default) or blue
rgbPlot(profile = profile, origSDM = spMod,
        dual_col = "purple", absence_col = "blue")

charliem2003/sdmProfiling documentation built on June 13, 2022, 4:43 a.m.