Skip to contents

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'.

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.

scenarios

The resulting stars objects.

Methods


Method new()

Initializes the object and creates an empty list

Usage

Returns

NULL


Method print()

Print the names and properties of all scenarios.

Usage

BiodiversityScenario$print()

Returns

A message on screen


Method verify()

Verify that set Model exist and check self-validity

Usage

BiodiversityScenario$verify()

Returns

Invisible


Method show()

Show the name of the Model

Usage

BiodiversityScenario$show()

Returns

Model objectname


Method get_projection()

Get projection of the projection.

Usage

BiodiversityScenario$get_projection()

Returns

A sf object with the geographic projection


Method get_resolution()

Get resultion of the projection.

Usage

BiodiversityScenario$get_resolution()

Returns

A numeric indication of the resolution.


Method get_model()

Get the actual model used for projection

Usage

BiodiversityScenario$get_model()

Returns

A DistributionModel object.


Method get_limits()

Get provided projection limits if set.

Usage

BiodiversityScenario$get_limits()

Returns

A sf object or NULL.


Method get_predictor_names()

Get names of predictors for scenario object.

Usage

BiodiversityScenario$get_predictor_names()

Returns

A character vector with the names.


Method get_timeperiod()

Get time period of projection.

Usage

BiodiversityScenario$get_timeperiod(what = "range")

Arguments

what

character on whether full time period or just the range is to be returned.

Returns

A time period from start to end.


Method get_constraints()

Get constrains for model

Usage

BiodiversityScenario$get_constraints()

Returns

A list with the constraints within the scenario.


Method get_threshold()

Get thresholds if specified.

Usage

BiodiversityScenario$get_threshold()

Returns

A list with method and value for the threshold.


Method get_thresholdvalue()

Duplicate function for internal consistency to return threshold

Usage

BiodiversityScenario$get_thresholdvalue()

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.

Returns

This object.


Method set_predictors()

Set new predictors to this object.

Usage

BiodiversityScenario$set_predictors(x)

Arguments

x

PredictorDataset object to be supplied.

Returns

This object.


Method set_constraints()

Set new constrains

Usage

BiodiversityScenario$set_constraints(x)

Arguments

x

A SpatRaster object to be added as as constraint.

Returns

This object.


Method get_simulation()

Get simulation options and parameters if gound

Usage

BiodiversityScenario$get_simulation()

Returns

A list with the parameters.


Method set_simulation()

Set simulation objects.

Usage

BiodiversityScenario$set_simulation(x)

Arguments

x

new simulation entries and options as list to be set.

Returns

This object.


Method get_predictors()

Get Predictors from the object.

Usage

BiodiversityScenario$get_predictors()

Returns

A predictor dataset.


Method rm_predictors()

Remove predictors from the object.

Usage

BiodiversityScenario$rm_predictors(names)

Arguments

names

A character vector with names

Returns

This object.


Method get_data()

Get scenario predictions or any other data

Usage

BiodiversityScenario$get_data(what = "scenarios")

Arguments

what

A character vector with names of what

Returns

This object.


Method set_data()

Set new data in object.

Usage

BiodiversityScenario$set_data(x)

Arguments

x

A new data object measuing scenarios.

Returns

This object.


Method plot()

Plot the predictions made here.

Usage

BiodiversityScenario$plot(what = "suitability", which = NULL, ...)

Arguments

what

A character describing the layers to be plotted.

which

A numeric subset to any specific time steps.

...

Any other parameters passed on.

Returns

A graphical representation


Method plot_threshold()

Convenience function to plot thresholds if set

Usage

BiodiversityScenario$plot_threshold(which = NULL)

Arguments

which

A numeric subset to any specific time steps.

Returns

A graphical representation


Method plot_migclim()

Plot Migclim results if existing.

Usage

BiodiversityScenario$plot_migclim()

Returns

A graphical representation


Method plot_animation()

Plot animation of scenarios if possible

Usage

BiodiversityScenario$plot_animation(what = "suitability", fname = NULL)

Arguments

what

A character describing the layers to be plotted.

fname

An optional filename to write the result.

Returns

A graphical representation


Method plot_relative_change()

Plot relative change between baseline and projected thresholds

Usage

BiodiversityScenario$plot_relative_change(
  position = NULL,
  variable = "mean",
  plot = TRUE
)

Arguments

position

Which layer to be plotted

variable

A character of the variable to be plotted

plot

logical flag on whether to plot the results or return the object.

Returns

A graphical representation or SpatRaster.


Method summary()

Summarize the change in layers between timesteps

Usage

BiodiversityScenario$summary(
  layer = "threshold",
  plot = FALSE,
  relative = FALSE
)

Arguments

layer

A character of the variable to be plotted

plot

logical flag on whether to plot the results or return the coefficients.

relative

logical on coefficients to be converted to relative change.

Returns

Summarized coefficients as data.frame


Method summary_beforeafter()

Summarize before-after change of first and last layer.

Usage

BiodiversityScenario$summary_beforeafter()

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"
)

Arguments

what

A character with layer to be plotted (default: "suitability").

plot

logical flag on whether to plot the results or return the coefficients.

oftype

character of the output type.

Returns

A SpatRaster layer or stars object.


Method mask()

Convenience function to mask all input projections.

Usage

BiodiversityScenario$mask(mask, inverse = FALSE, ...)

Arguments

mask

A SpatRaster or sf object.

inverse

A logical flag if the inverse should be masked instead.

...

Any other parameters passed on.

Returns

Invisible


Method get_centroid()

Get centroids of projection layers

Usage

BiodiversityScenario$get_centroid(patch = FALSE)

Arguments

patch

A logical if centroid should be calculated weighted by values.

Returns

Returns a sf object.


Method save()

Save object as output somewhere

Usage

BiodiversityScenario$save(fname, type = "tif", dt = "FLT4S")

Arguments

fname

An output filename as character.

type

A format as character. Matched against a list of supported formats.

dt

The datatype used, such as float64

Returns

Saved spatial prediction on drive.


Method clone()

The objects of this class are cloneable with this method.

Usage

BiodiversityScenario$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.