leveragePlot | R 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
leveragePlot( profile, origSDM, leverage_type = "dual-leverage", col = "red", plot_type = "points", save_plots = FALSE )
profile |
the output from |
origSDM |
a raster file of the probability of occurrences of the original
SDM built using the sampled cells (i.e. those in |
leverage_type |
which leverage type to plot. One of |
col |
the colour ramp to use (default = "red"). Low values are white |
plot_type |
either |
save_plots |
TRUE or FALSE (default) whether to save the final plot to a ggplot object |
Automatically generates a map of leverage values. If Use
plot_type = "points"
each profiled cell will be represented by a
point with colour and size relative to the leverage value, and the
background will be the original SDM map. If all unsampled cells have been
profiled use "raster"
will plot the profiled cells as a raster map,
with cell colour representing the leverage value.
Optionally, if save_plot = TRUE will output the ggplot object.
Charlie Marsh (charlie.marsh@mailbox.org) & Yoni Gavish
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) ### leveragePlot(profile = profile, origSDM = spMod, plot_type = "raster", leverage_type = "dual_leverage", col = "forest green") leveragePlot(profile = profile, origSDM = spMod, plot_type = "raster", leverage_type = "presence_leverage", col = "red") #' ### the full set of unsampled points to profile unsampPts <- data.frame(x = sample(1:25, 25), y = sample(1:25, 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) leveragePlot(profile = profile, origSDM = spMod, leverage_type = "presence_leverage", col = "red", plot_type = "points")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.