Package 'climateStability'

Title: Estimating Climate Stability from Climate Model Data
Description: Climate stability measures are not formalized in the literature and tools for generating stability metrics from existing data are nascent. This package provides tools for calculating climate stability from raster data encapsulating climate change as a series of time slices. The methods follow Owens and Guralnick <doi:10.17161/bi.v14i0.9786> Biodiversity Informatics.
Authors: Hannah Owens [aut, cre]
Maintainer: Hannah Owens <[email protected]>
License: GPL-3
Version: 0.1.4
Built: 2024-11-19 05:27:26 UTC
Source: https://github.com/hannahlowens/climatestability

Help Index


absLatitudinalMean

Description

A function to calculate mean values of a 'SpatRaster' at the absolute value of latitude, at the resolution of the given raster layer.

Usage

absLatitudinalMean(rasterForCalculation)

Arguments

rasterForCalculation

A 'SpatRaster' that contains data for plotting according to latitudinal value

Value

A vector of mean values for each absolute latitude value.

References

Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786

See Also

latitudinalMean for calculating mean values of rasters for all latitudinal bands.

Examples

precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc",
                                           package = "climateStability"))
precipStability <- 1/precipDeviation
alm <- absLatitudinalMean(rasterForCalculation = precipStability)
plot(alm, main = "Precipitation Stability by Absolute Latitude",
ylab = "Relative Stability", type = "l")

Calculating deviation through time

Description

A function that reads time-slice rasters of data for a given climate (typically processed data from a climate model run, such as the results of an analysis using PaleoView (Fordham, *et al.* 2017, Ecography)) in a given directory and calculates average deviation per year across time slices.

Usage

deviationThroughTime(variableDirectory, timeSlicePeriod, fileExtension = "asc")

Arguments

variableDirectory

A directory containing at least two time slice rasters for a given climate variable.

timeSlicePeriod

Either a single number, in years, representing the time period elapsed between temporally-even climate variable raster slices, or a vector corresponding to periods, in years, between temporally-uneven time slices.

fileExtension

a character that describes a fileExtension corresponding to one of the suported drivers in gdal

Details

Make sure that files in the 'variableDirectory' are read into 'R' in order.

If you are specifying temporally-uneven time slices with 'timeSlicePeriod', make sure that each number corresponds to the number of years elapsed *between* time slices, *in the same order as the files were read into 'R'*. There should be one less number than the number of files, and you must have at least three files in the directory.

See 'precipDeviation.asc' and 'temperatureDeviation.asc' for examples of rasters created using this function. See reference for data source details.

Value

A raster showing the geographic distribution of climate deviation through time for a particular climate variable.

References

Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786

Examples

# Generate sample data
td <- tempdir()
suppressWarnings(x <- terra::rast(nrows=20, ncols=20,
                                  xmin=0, xmax=10, ymin=0, ymax=10,
                                  vals = c(10,10,10,10,20)))
x2 <- x * 1.01
rastStack <- c(x, x2, x)
terra::writeRaster(rastStack, filename = paste0(td, "/raster",
                                                1:terra::nlyr(rastStack), ".tif"),
                   overwrite = TRUE)

# Even time slices
testResult <- deviationThroughTime(td, timeSlicePeriod = 100,
                                   fileExtension = "tif")

# Uneven time slices
testResult <- deviationThroughTime(variableDirectory = td,
                                   timeSlicePeriod = c(25, 100),
                                   fileExtension = "tif")
# Delete temporary files
unlink(td)

latitudinalMean

Description

A function to calculate mean values of a raster at every line of latitude, at the resolution of a given raster layer. Put another way, for each row in the raster, it calculates a mean.

Usage

latitudinalMean(rasterForCalculation)

Arguments

rasterForCalculation

A raster that contains data for plotting according to latitudinal value

Value

A vector of raster values for each absolute value of latitude.

References

Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786

See Also

absLatitudinalMean to calculate mean value for each absolute value of latitude.

Examples

precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc",
                                            package = "climateStability"))
precipStability <- 1/precipDeviation
latMean <- latitudinalMean(rasterForCalculation = precipStability)
plot(latMean, main = "Precipitation Stability by Latitude",
ylab = "Relative Stability", type = "l")

Rescale raster from 0 to 1

Description

A function to rescale a raster from 0 to 1. This is done using the formula (value-min)/(max-min).

Usage

rescale0to1(rasterForCalculation)

Arguments

rasterForCalculation

A 'SpatRaster' that contains data to be rescaled

Value

A raster that has been rescaled from 0 to 1

References

Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786

Examples

precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc",
                                           package = "climateStability"))
precipStability <- 1/precipDeviation
relativeClimateStability <- rescale0to1(precipStability)

Calculate stability from deviation

Description

A function to calculate stability based on the results of 'deviationThroughTime'.

Usage

stabilityCalc(rasterForCalculation)

Arguments

rasterForCalculation

A 'SpatRaster' object that contains data from which stability is to be calculated.

Details

This formula takes the inverse of the raster and rescales it from 0 to 1.This function is necessary in cases where there is no deviation in some cells. If time slices are very close together, it's possible that some cells may have values equal to zero, at which point if you simply divide 1 by the raster and rescale the result, you can end up with a raster full of zeroes.

Value

A raster

References

Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786

Examples

precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc",
                                           package = "climateStability"))
precipStability <- stabilityCalc(precipDeviation)