Package 'insights'

Title: An R implementation of the InSiGHTS framework
Description: The package provides an implementation of the InSiGHTS modelling framework for creating climate and land-use indicators. This package acts a simple wrapper to do an area-of-habitat refinements on top of climatic envelope models or species distribution models (SDMs). By default it is assumed that such models are obtained through the ibis.iSDM package and this package contains a simple wrapper to link the two approaches.
Authors: Martin Jung [aut, cre]
Maintainer: Martin Jung <[email protected]>
License: CC BY 4.0
Version: 0.6
Built: 2025-02-12 04:42:33 UTC
Source: https://github.com/iiasa/insights

Help Index


Recreate a derivative variable based on their range

Description

The purpose of this function is to create the range from several derivative variables. The information to do so is taken from the variable name and it is assumed that those have been created by ibis.iSDM::predictor_derivate() function.

This function return the range of values from the original data that fall within the set of coefficients. Currently only positive coefficients are taken by default.

Usage

create_derivate_range(env, varname, co, to_binary = FALSE)

Arguments

env

The original variable stacks as SpatRaster or stars.

varname

A character of the variable name. Needs to be present in "env".

co

A set of coefficients obtained via stats::coef() and a ibis.iSDM::BiodiversityDistribution object.

to_binary

A logical flag if the output should be converted to binary format or left in the original units (Default: FALSE).

Details

  • This function really only makes sense for 'bin', 'thresh' and 'hinge' transformations.

  • For 'hinge' the combined min is returned.

Value

A SpatRaster object containing the predictor range.

Note

This is rather an internal function created for a specific use and project. It might be properly described in an example later.

Author(s)

Martin Jung

Examples

## Not run: 
 # Assuming derivates of temperature have been created for a model, this
 # recreates the range over which they apply.
 deriv <- create_derivate_range(env, varname = "Temperature",
  co = coef(fit), to_binary = TRUE)

## End(Not run)

Apply InSiGHTS with continuous areal land use data

Description

This function applies an area-of-habitat (AOH) correction to a provided single time step or multiple step range estimate (binary or other format). This thus assumes that species-habitat relations remain stable also in future conditions within a provided climatic niche.

Opposed to insights_fraction it is assumed that the land-use layers come in continuous areal units, such as 'km2'. Optionally also a elevation (elev) layer and habitat condition (condition) can be provided to support refinements by elevational range or habitat condition.

Usage

insights_area(range, lu, other, outfile = NULL)

## S4 method for signature 'SpatRaster,SpatRaster,SpatRaster,character'
insights_area(range,lu,other,outfile)

## S4 method for signature 'SpatRaster,stars,ANY,character'
insights_area(range,lu,other,outfile)

## S4 method for signature 'stars,stars,ANY,character'
insights_area(range,lu,other,outfile)

## S4 method for signature 'stars,stars,ANY,character'
insights_area(range,lu,other,outfile)

## S4 method for signature 'ANY,ANY,SpatRaster,character'
insights_area(range,lu,other,outfile)

Arguments

range

A SpatRaster or temporal stars object describing the estimated distribution of a biodiversity feature (e.g. species). Alternatively a DistributionModel fitted with ibis.iSDM package can be supplied.

lu

A SpatRaster or temporal stars object of the future land-use areas to be applied to the range. Each layer has to be in units of area, so greater 0

other

Any other SpatRaster or temporal stars objects that describe suitable conditions for the species.

outfile

A writeable character of where the output should be written to. If missing, the the function will return a SpatRaster or stars object respectively.

Value

Either a SpatRaster or temporal stars object or nothing if outputs are written directly to drive.

Note

This function does not do the refinement of land-use fraction to relevant habitats. This needs to be done by the analyst a-priori. No checks are conducted on whether area shares match or exceed certain amounts!

Author(s)

Martin Jung

References

  • Rondinini, Carlo, and Piero Visconti. "Scenarios of large mammal loss in Europe for the 21st century." Conservation Biology 29, no. 4 (2015): 1028-1036.

  • Visconti, Piero, Michel Bakkenes, Daniele Baisero, Thomas Brooks, Stuart HM Butchart, Lucas Joppa, Rob Alkemade et al. "Projecting global biodiversity indicators under future development scenarios." Conservation Letters 9, no. 1 (2016): 5-13.

Examples

## Not run: 
 out <- insights_area(range, landuse_km2)

## End(Not run)

Apply InSiGHTS with fractional land use data

Description

This function applies an area-of-habitat (AOH) correction to a provided single time step or multiple step range estimate (binary format). This thus assumes that species-habitat relations remain stable also in future conditions within a provided climatic niche.

It is assumed that the land-use layers come in fractional units, so are ranging from 0 to 1. Optionally also a elevation (elev) layer and habitat condition (condition) can be provided to support refinements by elevational range or habitat condition.

Usage

insights_fraction(range, lu, other, outfile = NULL, clamp = FALSE)

## S4 method for signature 'SpatRaster,SpatRaster,SpatRaster,character,logical'
insights_fraction(range,lu,other,outfile,clamp)

## S4 method for signature 'SpatRaster,stars,ANY,character,logical'
insights_fraction(range,lu,other,outfile,clamp)

## S4 method for signature 'stars,stars,ANY,character,logical'
insights_fraction(range,lu,other,outfile,clamp)

## S4 method for signature 'stars,stars,ANY,character,logical'
insights_fraction(range,lu,other,outfile,clamp)

## S4 method for signature 'ANY,ANY,SpatRaster,character,logical'
insights_fraction(range,lu,other,outfile,clamp)

Arguments

range

A SpatRaster or temporal stars object describing the estimated distribution of a biodiversity feature (e.g. species). Has to be in binary format! Alternatively a DistributionModel fitted with ibis.iSDM package can be supplied.

lu

A SpatRaster or temporal stars object of the future land-use fractions to be applied to the range. Each layer has to be in units of fractions, e.g. between 0 and 1.

other

Any other SpatRaster or temporal stars objects that describe suitable conditions for the species.

outfile

A writeable character of where the output should be written to. If missing, the the function will return a SpatRaster or stars object respectively.

clamp

A logical on whether lu should be clamped to 0 and 1 beforehand (Default: FALSE).

Value

Either a SpatRaster or temporal stars object or nothing if outputs are written directly to drive.

Note

This function does not do the refinement of land-use fraction to relevant habitats. This needs to be done by the analyst a-priori.

Author(s)

Martin Jung

References

  • Rondinini, Carlo, and Piero Visconti. "Scenarios of large mammal loss in Europe for the 21st century." Conservation Biology 29, no. 4 (2015): 1028-1036.

  • Visconti, Piero, Michel Bakkenes, Daniele Baisero, Thomas Brooks, Stuart HM Butchart, Lucas Joppa, Rob Alkemade et al. "Projecting global biodiversity indicators under future development scenarios." Conservation Letters 9, no. 1 (2016): 5-13.

Examples

## Not run: 
 out <- insights_fraction(range, landuse)

## End(Not run)

Summarize inSiGHTS into an index

Description

This function handily summarizes the suitable habitat for a given species or biodiversity feature into an index. If a single timestep (or object with a single layer) is provided, this function simply summarizes the suitable area.

Usage

insights_summary(obj, toArea = TRUE, fun = "sum", relative = TRUE)

## S4 method for signature 'SpatRaster,logical,character,logical'
insights_summary(obj,toArea,fun,relative)

## S4 method for signature 'stars,logical,character,logical'
insights_summary(obj,toArea,fun,relative)

Arguments

obj

A SpatRaster or temporal stars object describing with the applied InSiGHTS outputs from insights_fraction. If the number of layers is greater than 1, the parameter "relative" mgiht be applied.

toArea

A logical flag whether the suitable habitat should be summarized to area (Default: TRUE)?

fun

A character indicating the summary function to be applied (Default: 'sum'). Currently supported are 'sum', 'min', 'max', 'median' and 'mean'.

relative

A logical flag whether a relative index is to be constructed (Default: TRUE).

Value

A data.frame with area estimates or the respective indicator.

Author(s)

Martin Jung

References

  • Baisero, Daniele, Piero Visconti, Michela Pacifici, Marta Cimatti, and Carlo Rondinini. "Projected global loss of mammal habitat due to land-use and climate change." One Earth 2, no. 6 (2020): 578-585.

  • Powers, Ryan P., and Walter Jetz. "Global habitat loss and extinction risk of terrestrial vertebrates under future land-use-change scenarios." Nature Climate Change 9, no. 4 (2019): 323-329.


Relative change function

Description

This function calculates the relative change of a vector, taking the first value as a reference value.

Usage

relChange(v, fac = 100)

Arguments

v

A vector with numeric values greater than 2.

fac

A numeric constant multiplier on the resulting metric.

Value

A numeric vector.

Author(s)

Martin Jung

Examples

# Example vector
x <- c(20,6,2,1,15,25)
relChange(x)

Clamp stars to a specific bounds or range

Description

This small helper function simply clamps the a given SpatRaster or stars object \ to a provided range. This can help to adjust for example land-use fractions for use in insights_fraction().

Usage

st_clamp(env, lb = -Inf, ub = Inf)

Arguments

env

The original variable stacks as SpatRaster or stars.

lb

The lower bound for clamping (Default: -Inf).

ub

The lower bound for clamping (Default: Inf).

Value

The same as input 'env'.

Author(s)

Martin Jung

Examples

## Not run: 
  # Use

## End(Not run)