Skip to contents

An Rcpp module class exposing the C++ ClimateBlock implementation of the xbioclim library. Accepts four n_pixels x 12 matrices of monthly climate data and computes all 19 bioclimatic variables for each pixel via a compiled C++ back-end.

Value

new(ClimateBlock, tas, tasmax, tasmin, pr) returns an Rcpp module object of class ClimateBlock. Its $n_pixels() method returns a single integer and its $compute() method returns an n_pixels x 19 numeric matrix with columns named bio01 through bio19.

Details

ClimateBlock is loaded into the package namespace when the package is attached (via loadModule in .onLoad).

Constructor

new(ClimateBlock, tas, tasmax, tasmin, pr)

tas

Numeric matrix of dimensions n_pixels x 12: monthly mean temperature for each pixel.

tasmax

Numeric matrix of dimensions n_pixels x 12: monthly maximum temperature for each pixel.

tasmin

Numeric matrix of dimensions n_pixels x 12: monthly minimum temperature for each pixel.

pr

Numeric matrix of dimensions n_pixels x 12: monthly precipitation for each pixel.

All four matrices must have exactly 12 columns and the same number of rows.

Methods

n_pixels()

Returns the number of pixels (integer).

compute()

Computes the 19 bioclimatic variables for all pixels and returns an n_pixels x 19 numeric matrix with columns named bio01 through bio19.

Examples

tas    <- matrix(rep(1:12, 3), nrow = 3, byrow = TRUE)
tasmax <- tas + 1
tasmin <- tas - 1
pr     <- matrix(rep(1:12, 3), nrow = 3, byrow = TRUE)
block  <- new(ClimateBlock, tas, tasmax, tasmin, pr)
block$n_pixels()   # 3
#> [1] 3
result <- block$compute()   # 3 x 19 matrix