Class for a biodiversity scenario from a trained model
Source:R/class-biodiversityscenario.R
BiodiversityScenario-class.Rd
Base 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
modelobject
A name of the model for projection.
modelid
An id of the model used for projection.
limits
A
sf
object used to constraint the prediction.predictors
A predictor object for projection.
constraints
Any constraints set for projection.
latentfactors
A
list
on whether latentfactors are used.scenarios
The resulting
stars
objects.
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
copy
A
logical
flag 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
what
character
on 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
tr
A
numeric
value with the new threshold.
Method set_predictors()
Set new predictors to this object.
Arguments
x
PredictorDataset
object 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
x
new simulation entries and options as
list
to be set.
Method rm_predictors()
Remove predictors from the object.
Arguments
names
A
character
vector with names
Method get_data()
Get scenario predictions or any other data
Arguments
what
A
character
vector with names of what
Method set_latent()
Adding latent factors to the object.
Arguments
latent
A
list
containing the data object.
Method rm_latent()
Remove latent factors if found in object.
Method plot_threshold()
Convenience function to plot thresholds if set
Arguments
which
A
numeric
subset to any specific time steps.
Method plot_animation()
Plot animation of scenarios if possible
Arguments
what
A
character
describing the layers to be plotted.fname
An 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
patch
A
logical
if centroid should be calculated weighted by values.