
Class for a biodiversity scenario from a trained model
Source:R/class-biodiversityscenario.R
BiodiversityScenario-class.RdBase R6 class for any biodiversity scenario objects. Serves as
container that supplies data and functions to other R6 classes and functions.
Note
This sets the threshold method internally to 'fixed'.
The latent factor is usually obtained from the fitted model object, unless re-specified and added here to the list.
This requires the "gganimate" package.
This requires a set threshold() to the scenario object.
This requires set threshold prior to projection.
Public fields
modelobjectA name of the model for projection.
modelidAn id of the model used for projection.
limitsA
sfobject used to constraint the prediction.predictorsA predictor object for projection.
constraintsAny constraints set for projection.
latentfactorsA
liston whether latentfactors are used.scenariosThe resulting
starsobjects.logA
Logobject for capturing messages.
Methods
BiodiversityScenario$new()
Initializes the object and creates an empty list
Usage
BiodiversityScenario$new()BiodiversityScenario$get_projection()
Get projection of the projection.
Returns
A sf object with the geographic projection
BiodiversityScenario$get_resolution()
Get resultion of the projection.
Returns
A numeric indication of the resolution.
BiodiversityScenario$get_model()
Get the actual model used for projection
Arguments
copyA
logicalflag on whether a deep copy should be created.
BiodiversityScenario$get_limits()
Get provided projection limits if set.
Returns
A sf object or NULL.
BiodiversityScenario$get_predictor_names()
Get names of predictors for scenario object.
Returns
A character vector with the names.
BiodiversityScenario$get_timeperiod()
Get time period of projection.
Arguments
whatcharacteron whether full time period or just the range is to be returned.
BiodiversityScenario$get_constraints()
Get constrains for model
Returns
A list with the constraints within the scenario.
BiodiversityScenario$get_threshold()
Get thresholds if specified.
Returns
A list with method and value for the threshold.
BiodiversityScenario$get_thresholdvalue()
Duplicate function for internal consistency to return threshold
Returns
A list with method and value for the threshold.
BiodiversityScenario$apply_threshold()
Apply a new threshold to the projection.
Usage
BiodiversityScenario$apply_threshold(tr = new_waiver())Arguments
trA
numericvalue with the new threshold.
BiodiversityScenario$set_predictors()
Set new predictors to this object.
Arguments
xPredictorDatasetobject to be supplied.
BiodiversityScenario$set_constraints()
Set new constrains
Arguments
xA
listobject with constraint settings.
BiodiversityScenario$get_log()
Returns the output filename of the current log object if set.
Returns
A character where the output is returned.
BiodiversityScenario$get_simulation()
Get simulation options and parameters if gound
Returns
A list with the parameters.
BiodiversityScenario$set_simulation()
Set simulation objects.
Arguments
xnew simulation entries and options as
listto be set.
BiodiversityScenario$rm_predictors()
Remove predictors from the object.
Arguments
namesA
charactervector with names
BiodiversityScenario$get_data()
Get scenario predictions or any other data
Arguments
whatA
charactervector with names of what
BiodiversityScenario$set_latent()
Adding latent factors to the object.
Arguments
latentA
listcontaining the data object.
BiodiversityScenario$get_latent()
Get latent factors if found in object.
Returns
A list with the latent settings
BiodiversityScenario$plot_threshold()
Convenience function to plot thresholds if set
Arguments
whichA
numericsubset to any specific time steps.
BiodiversityScenario$plot_animation()
Plot animation of scenarios if possible
Arguments
whatA
characterdescribing the layers to be plotted.fnameAn optional filename to write the result.
BiodiversityScenario$plot_relative_change()
Plot relative change between baseline and projected thresholds
Returns
A graphical representation or SpatRaster.
BiodiversityScenario$summary()
Summarize the change in layers between timesteps
Returns
Summarized coefficients as data.frame
BiodiversityScenario$summary_beforeafter()
Summarize before-after change of first and last layer.
Returns
Summarized coefficients as data.frame
BiodiversityScenario$calc_scenarios_slope()
Calculate slopes across the projection
Usage
BiodiversityScenario$calc_scenarios_slope(
what = "suitability",
plot = TRUE,
oftype = "stars"
)Returns
A SpatRaster layer or stars object.
BiodiversityScenario$mask()
Convenience function to mask all input projections.
BiodiversityScenario$get_centroid()
Get centroids of projection layers
Arguments
patchA
logicalif centroid should be calculated weighted by values.
Returns
Returns a sf object.