
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.
Methods
Method print()
Print the names and properties of all scenarios.
Method get_resolution()
Get resultion of the projection.
Returns
A numeric indication of the resolution.
Method get_model()
Get the actual model used for projection
Arguments
copyA
logicalflag on whether a deep copy should be created.
Method get_predictor_names()
Get names of predictors for scenario object.
Returns
A character vector with the names.
Method get_timeperiod()
Get time period of projection.
Arguments
whatcharacteron whether full time period or just the range is to be returned.
Method get_constraints()
Get constrains for model
Returns
A list with the constraints within the scenario.
Method get_threshold()
Get thresholds if specified.
Returns
A list with method and value for the threshold.
Method get_thresholdvalue()
Duplicate function for internal consistency to return threshold
Returns
A list with method and value for the threshold.
Method apply_threshold()
Apply a new threshold to the projection.
Usage
BiodiversityScenario$apply_threshold(tr = new_waiver())Arguments
trA
numericvalue with the new threshold.
Method set_predictors()
Set new predictors to this object.
Arguments
xPredictorDatasetobject to be supplied.
Method get_simulation()
Get simulation options and parameters if gound
Returns
A list with the parameters.
Method set_simulation()
Set simulation objects.
Arguments
xnew simulation entries and options as
listto be set.
Method rm_predictors()
Remove predictors from the object.
Arguments
namesA
charactervector with names
Method get_data()
Get scenario predictions or any other data
Arguments
whatA
charactervector with names of what
Method set_latent()
Adding latent factors to the object.
Arguments
latentA
listcontaining the data object.
Method rm_latent()
Remove latent factors if found in object.
Method plot_threshold()
Convenience function to plot thresholds if set
Arguments
whichA
numericsubset to any specific time steps.
Method plot_animation()
Plot animation of scenarios if possible
Arguments
whatA
characterdescribing the layers to be plotted.fnameAn optional filename to write the result.
Method plot_relative_change()
Plot relative change between baseline and projected thresholds
Method summary()
Summarize the change in layers between timesteps
Returns
Summarized coefficients as data.frame
Method summary_beforeafter()
Summarize before-after change of first and last layer.
Returns
Summarized coefficients as data.frame
Method 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.
Method mask()
Convenience function to mask all input projections.
Method get_centroid()
Get centroids of projection layers
Arguments
patchA
logicalif centroid should be calculated weighted by values.