Type: | Package |
Title: | Scalable and Efficient Derivation of Bioclimatic Variables |
Version: | 0.2.1 |
Maintainer: | Gonzalo E. Pinilla-Buitrago <gepinillab@gmail.com> |
Description: | Provides a high-performance framework for deriving bioclimatic and custom summary variables from large-scale climate raster data. The package features a dual-backend architecture that intelligently switches between fast in-memory processing for smaller datasets (via the 'terra' package) and a memory-safe tiled approach for massive datasets that do not fit in RAM (via 'exactextractr' and 'Rfast'). The main functions, 'derive_bioclim()' and 'derive_statistics()', offer a unified interface with advanced options for custom time periods and static indices, making it suitable for a wide range of ecological and environmental modeling applications. A software note is in preparation. In the meantime, you can visit the package website https://gepinillab.github.io/fastbioclim/ to find tutorials in English and Spanish. |
License: | GPL (≥ 3) |
URL: | https://gepinillab.github.io/fastbioclim/ |
BugReports: | https://github.com/gepinillab/fastbioclim/issues |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 4.1) |
Imports: | exactextractr, future.apply, glue, progressr, purrr, qs, Rfast, rlang, sf, terra (≥ 1.7-0) |
NeedsCompilation: | no |
Packaged: | 2025-09-02 17:37:29 UTC; gepb |
Author: | Gonzalo E. Pinilla-Buitrago
|
Repository: | CRAN |
Date/Publication: | 2025-09-08 19:10:02 UTC |
Tiled, Out-of-Core Time Series Averaging (Internal)
Description
Tiled, Out-of-Core Time Series Averaging (Internal)
Usage
average_fast(paths, index, output_names, user_region, tile_degrees, output_dir)
In-Memory Time Series Averaging (Internal)
Description
In-Memory Time Series Averaging (Internal)
Usage
average_terra(x, index, output_names, output_dir, gdal_opt, overwrite)
bio01_fast: Mean Temperature of Units
Description
Calculates mean temperature across all temporal units.
Usage
bio01_fast(tavg, cell)
Arguments
tavg |
Matrix of average temperatures for each unit. |
cell |
Vector of original cell IDs. |
Value
Matrix with columns: "bio01", "cell".
bio01_terra: Mean Temperature of Units
Description
Calculates mean temperature across all temporal units.
Usage
bio01_terra(tavg)
Arguments
tavg |
spatRaster of average temperatures for each unit. |
Value
spatRaster with "bio01".
bio02_fast: Mean Diurnal Range
Description
Calculates the mean of (tmax - tmin) across all temporal units.
Usage
bio02_fast(tmin, tmax, cell)
Arguments
tmin |
Matrix of minimum temperatures for each unit. |
tmax |
Matrix of maximum temperatures for each unit. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio02", "cell".
bio02_terra: Mean Diurnal Range
Description
Calculates the mean of (tmax - tmin) across all temporal units.
Usage
bio02_terra(tmin, tmax)
Arguments
tmin |
spatRaster of minimum temperatures for each unit. |
tmax |
spatRaster of maximum temperatures for each unit. |
Value
spatRaster with "bio02".
bio03_fast: Isothermality
Description
Calculates (bio02 / bio07) * 100.
Usage
bio03_fast(bio02V, bio07V, cell)
Arguments
bio02V |
Vector or single-column matrix of bio02 values. |
bio07V |
Vector or single-column matrix of bio07 values. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio03", "cell".
bio03_terra: Isothermality
Description
Calculates (bio02 / bio07) * 100.
Usage
bio03_terra(bio02, bio07)
Arguments
bio02 |
spatRaster of bio02 values. |
bio07 |
spatRaster of bio07 values. |
Value
spatRaster with "bio03".
bio04_fast: Temperature Seasonality (Std Dev * 100)
Description
Calculates the standard deviation of average temperatures across units, multiplied by 100.
Usage
bio04_fast(tavg, cell)
Arguments
tavg |
Matrix of average temperatures for each unit. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio04", "cell".
bio04_terra: Temperature Seasonality (Std Dev * 100)
Description
Calculates the standard deviation of average temperatures across units, multiplied by 100.
Usage
bio04_terra(tavg)
Arguments
tavg |
spatRaster of average temperatures for each unit. |
Value
spatRaster with "bio04".
bio05_fast: Max Temperature of Warmest Unit
Description
Identifies max temperature of the warmest unit, potentially using a static index.
Usage
bio05_fast(tmax, cell, index_vector = NULL)
Arguments
tmax |
Matrix of maximum temperatures for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts Tmax for that unit. If NULL, finds overall max Tmax. |
Value
Matrix with "bio05", "cell".
bio05_terra: Max Temperature of Warmest Unit
Description
Identifies max temperature of the warmest unit, potentially using a static index.
Usage
bio05_terra(tmax, warmest_unit = NULL)
Arguments
tmax |
spatRaster of maximum temperatures for each unit. |
Value
spatRaster with "bio05".
bio06_fast: Min Temperature of Coldest Unit
Description
Identifies min temperature of the coldest unit, potentially using a static index.
Usage
bio06_fast(tmin, cell, index_vector = NULL)
Arguments
tmin |
Matrix of minimum temperatures for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts Tmin for that unit. If NULL, finds overall min Tmin. |
Value
Matrix with "bio06", "cell".
bio06_terra: Min Temperature of Coldest Unit
Description
Identifies min temperature of the coldest unit, potentially using a static index.
Usage
bio06_terra(tmin, coldest_unit = NULL)
Arguments
tmin |
spatRaster of minimum temperatures for each unit. |
Value
spatRaster with "bio06".
bio07_fast: Temperature Annual Range (bio05 - bio06)
Description
Calculates the difference between bio05 and bio06.
Usage
bio07_fast(bio05V, bio06V, cell)
Arguments
bio05V |
Vector or single-column matrix of bio05 values. |
bio06V |
Vector or single-column matrix of bio06 values. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio07", "cell".
bio07_terra: Temperature Annual Range (bio05 - bio06)
Description
Calculates the difference between bio05 and bio06.
Usage
bio07_terra(bio05, bio06)
Arguments
bio05 |
spatRaster of bio05 values. |
bio06 |
spatRaster of bio06 values. |
Value
spatRaster with "bio07".
bio08_fast: Mean Temperature of Wettest Period
Description
Calculates mean temperature of the period with the highest precipitation sum.
Usage
bio08_fast(tperiod, pperiod_max_idx, period_length, cell)
Arguments
tperiod |
Matrix of temperature period sums (output from 'var_periods'). |
pperiod_max_idx |
Vector indicating the index (1-based) of the wettest period for each row. |
period_length |
Integer. Number of units per period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio08", "cell".
bio08_terra: Mean Temperature of Wettest Period
Description
Calculates mean temperature of the period with the highest precipitation sum.
Usage
bio08_terra(tmp, wettest_period)
Arguments
tmp |
spatRaster of temperature period sums. |
wettest_period |
spatRaster indicating the index (1-based) of the wettest period for each cell. |
Value
spatRaster with "bio08".
bio09_fast: Mean Temperature of Driest Period
Description
Calculates mean temperature of the period with the lowest precipitation sum.
Usage
bio09_fast(tperiod, pperiod_min_idx, period_length, cell)
Arguments
tperiod |
Matrix of temperature period sums. |
pperiod_min_idx |
Vector indicating the index (1-based) of the driest period. |
period_length |
Integer. Number of units per period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio09", "cell".
bio09_terra: Mean Temperature of Driest Period
Description
Calculates mean temperature of the period with the lowest precipitation sum.
Usage
bio09_terra(tmp, driest_period)
Arguments
tmp |
spatRaster of temperature period sums. |
driest_period |
Vector indicating the index (1-based) of the driest period. |
Value
spatRaster with "bio09".
bio10_fast: Mean Temperature of Warmest Period
Description
Calculates mean temperature of the period with the highest temperature sum.
Usage
bio10_fast(tperiod, tperiod_max_idx, period_length, cell)
Arguments
tperiod |
Matrix of temperature period sums. |
tperiod_max_idx |
Vector indicating the index (1-based) of the warmest period. |
period_length |
Integer. Number of units per period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio10", "cell".
bio10_terra: Mean Temperature of Warmest Period
Description
Calculates mean temperature of the period with the highest temperature sum.
Usage
bio10_terra(tmp, warmest_period)
Arguments
tmp |
spatRaster of temperature period sums. |
warmest_period |
Vector indicating the index (1-based) of the warmest period. |
Value
spatRaster with "bio10".
bio11_fast: Mean Temperature of Coldest Period
Description
Calculates mean temperature of the period with the lowest temperature sum.
Usage
bio11_fast(tperiod, tperiod_min_idx, period_length, cell)
Arguments
tperiod |
Matrix of temperature period sums. |
tperiod_min_idx |
Vector indicating the index (1-based) of the coldest period. |
period_length |
Integer. Number of units per period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio11", "cell".
bio11_terra: Mean Temperature of Coldest Period
Description
Calculates mean temperature of the period with the lowest temperature sum.
Usage
bio11_terra(tmp, coldest_period)
Arguments
tmp |
spatRaster of temperature period sums. |
coldest_period |
Vector indicating the index (1-based) of the coldest period. |
Value
spatRaster with "bio11".
bio12_fast: Total Precipitation
Description
Calculates the sum of precipitation values across all units.
Usage
bio12_fast(prcp, cell)
Arguments
prcp |
Matrix of precipitation values for each unit. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio12", "cell".
bio12_terra: Total Precipitation
Description
Calculates the sum of precipitation values across all units.
Usage
bio12_terra(prcp)
Arguments
prcp |
spatRaster of precipitation values for each unit. |
Value
spatRaster with "bio12".
bio13_fast: Precipitation of Wettest Unit
Description
Identifies precipitation of the wettest unit, potentially using a static index.
Usage
bio13_fast(prcp, cell, index_vector = NULL)
Arguments
prcp |
Matrix of precipitation values for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts Prec for that unit. If NULL, finds overall max Prec. |
Value
Matrix with "bio13", "cell".
bio13_terra: Precipitation of Wettest Unit
Description
Identifies precipitation of the wettest unit, potentially using a static index.
Usage
bio13_terra(prcp, wettest_unit = NULL)
Arguments
prcp |
spatRaster of precipitation values for each unit. |
Value
spatRaster with "bio13".
bio14_fast: Precipitation of Driest Unit
Description
Identifies precipitation of the driest unit, potentially using a static index.
Usage
bio14_fast(prcp, cell, index_vector = NULL)
Arguments
prcp |
Matrix of precipitation values for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts Prec for that unit. If NULL, finds overall min Prec. |
Value
Matrix with "bio14", "cell".
bio14_terra: Precipitation of Driest Unit
Description
Identifies precipitation of the driest unit, potentially using a static index.
Usage
bio14_terra(prcp, driest_unit = NULL)
Arguments
prcp |
spatRaster of precipitation values for each unit. |
Value
spatRaster with "bio14".
bio15_fast: Precipitation Seasonality (CV)
Description
Calculates coefficient of variation in precipitation across units.
Usage
bio15_fast(prcp, bio12V, n_units, cell)
Arguments
prcp |
Matrix containing precipitation values for each unit. |
bio12V |
Precomputed total precipitation (BIO12 value). |
n_units |
Integer. The total number of temporal units. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio15", "cell".
bio15_terra: Precipitation Seasonality (CV)
Description
Calculates coefficient of variation in precipitation across units.
Usage
bio15_terra(prcp)
Arguments
prcp |
Matrix containing precipitation values for each unit. |
Value
spatRaster with "bio15".
Note
The "1 +" is to avoid strange CVs for areas where mean rainfaill is < 1)
bio16_fast: Precipitation of Wettest Period
Description
Calculates precipitation sum of the period with the highest precipitation sum.
Usage
bio16_fast(pperiod, pperiod_max_idx, cell)
Arguments
pperiod |
Matrix of precipitation period sums (output from 'var_periods'). |
pperiod_max_idx |
Vector indicating the index (1-based) of the wettest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio16", "cell".
bio16_terra: Precipitation of Wettest Period
Description
Calculates precipitation sum of the period with the highest precipitation sum.
Usage
bio16_terra(wet, wettest_period)
Arguments
wet |
spatRaster of precipitation period sums. |
wettest_period |
Vector indicating the index (1-based) of the wettest period. |
Value
spatRaster with "bio16".
bio17_fast: Precipitation of Driest Period
Description
Calculates precipitation sum of the period with the lowest precipitation sum.
Usage
bio17_fast(pperiod, pperiod_min_idx, cell)
Arguments
pperiod |
Matrix of precipitation period sums. |
pperiod_min_idx |
Vector indicating the index (1-based) of the driest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio17", "cell".
bio17_terra: Precipitation of Driest Period
Description
Calculates precipitation sum of the period with the lowest precipitation sum.
Usage
bio17_terra(wet, driest_period)
Arguments
wet |
spatRaster of precipitation period sums. |
driest_period |
Vector indicating the index (1-based) of the driest period. |
Value
spatRaster with "bio17".
bio18_fast: Precipitation of Warmest Period
Description
Calculates precipitation sum of the period with the highest temperature sum.
Usage
bio18_fast(pperiod, tperiod_max_idx, cell)
Arguments
pperiod |
Matrix of precipitation period sums. |
tperiod_max_idx |
Vector indicating the index (1-based) of the warmest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio18", "cell".
bio18_terra: Precipitation of Warmest Period
Description
Calculates precipitation sum of the period with the highest temperature sum.
Usage
bio18_terra(wet, warmest_period)
Arguments
wet |
spatRaster of precipitation period sums. |
warmest_period |
Vector indicating the index (1-based) of the warmest period. |
Value
spatRaster with "bio18".
bio19_fast: Precipitation of Coldest Period
Description
Calculates precipitation sum of the period with the lowest temperature sum.
Usage
bio19_fast(pperiod, tperiod_min_idx, cell)
Arguments
pperiod |
Matrix of precipitation period sums. |
tperiod_min_idx |
Vector indicating the index (1-based) of the coldest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio19", "cell".
bio19_terra: Precipitation of Coldest Period
Description
Calculates precipitation sum of the period with the lowest temperature sum.
Usage
bio19_terra(wet, coldest_period)
Arguments
wet |
spatRaster of precipitation period sums. |
coldest_period |
Vector indicating the index (1-based) of the coldest period. |
Value
spatRaster with "bio19".
bio20_fast: Mean Solar Radiation of Units
Description
Calculates mean solar radiation across all temporal units.
Usage
bio20_fast(srad, cell)
Arguments
srad |
Matrix of average solar radiation for each unit. |
cell |
Vector of original cell IDs. |
Value
Matrix with columns: "bio20", "cell".
bio20_terra: Mean Solar Radiation of Units
Description
Calculates mean solar radiation across all temporal units.
Usage
bio20_terra(srad)
Arguments
srad |
spatRaster of average solar radiation for each unit. |
Value
spatRaster with "bio20".
bio21_fast: Highest Solar Radiation Unit
Description
Identifies highest solar radiation unit, potentially using a static index.
Usage
bio21_fast(srad, cell, index_vector = NULL)
Arguments
srad |
Matrix of solar radiation values for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts Srad for that unit. If NULL, finds overall max Srad. |
Value
Matrix with "bio21", "cell".
bio21_terra: Highest Solar Radiation Unit
Description
Identifies highest solar radiation unit, potentially using a static index.
Usage
bio21_terra(srad, high_rad_unit = NULL)
Arguments
srad |
spatRaster of solar radiation values for each unit. |
Value
spatRaster with "bio21".
bio22_fast: Lowest Solar Radiation Unit
Description
Identifies lowest solar radiation unit, potentially using a static index.
Usage
bio22_fast(srad, cell, index_vector = NULL)
Arguments
srad |
Matrix of solar radiation values for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts Srad for that unit. If NULL, finds overall max Srad. |
Value
Matrix with "bio22", "cell".
bio22_terra: Lowest Solar Radiation Unit
Description
Identifies lowest solar radiation unit, potentially using a static index.
Usage
bio22_terra(srad, low_rad_unit = NULL)
Arguments
srad |
spatRaster of solar radiation values for each unit. |
Value
spatRaster with "bio22".
bio23_fast: Solar Radiation Seasonality (CV)
Description
Calculates coefficient of variation in solar radiation across units.
Usage
bio23_fast(srad, n_units, cell)
Arguments
srad |
Matrix containing solar radiation values for each unit. |
n_units |
Integer. The total number of temporal units. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio23", "cell".
bio23_terra: Solar Radiation Seasonality (CV)
Description
Calculates coefficient of variation in solar radiation across units.
Usage
bio23_terra(srad)
Arguments
srad |
Matrix containing solar radiation values for each unit. |
Value
spatRaster with "bio23".
bio24_fast: Solar Radiation of Wettest Period
Description
Calculates solar radiation mean of the period with the highest precipitation sum.
Usage
bio24_fast(speriod, pperiod_max_idx, cell)
Arguments
speriod |
Matrix of solar radiation period means (output from 'var_periods'). |
pperiod_max_idx |
Vector indicating the index (1-based) of the wettest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio24", "cell".
bio24_terra: Solar Radiation of Wettest Period
Description
Calculates solar radiation mean of the period with the highest precipitation sum.
Usage
bio24_terra(prad, wettest_period)
Arguments
prad |
spatRaster of solar radiation period means. |
wettest_period |
Vector indicating the index (1-based) of the wettest period. |
Value
spatRaster with "bio24".
bio25_fast: Solar Radiation of Driest Period
Description
Calculates solar radiation mean of the period with the highest precipitation sum.
Usage
bio25_fast(speriod, pperiod_min_idx, cell)
Arguments
speriod |
Matrix of solar radiation period means (output from 'var_periods'). |
pperiod_min_idx |
Vector indicating the index (1-based) of the driest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio25", "cell".
bio25_terra: Solar Radiation of Driest Period
Description
Calculates solar radiation mean of the period with the highest precipitation sum.
Usage
bio25_terra(prad, driest_period)
Arguments
prad |
spatRaster of solar radiation period means. |
driest_period |
Vector indicating the index (1-based) of the driest period. |
Value
spatRaster with "bio25".
bio26_fast: Solar Radiation of Warmest Period
Description
Calculates solar radiation mean of the period with the highest temperature mean.
Usage
bio26_fast(speriod, tperiod_max_idx, cell)
Arguments
speriod |
Matrix of solar radiation period means (output from 'var_periods'). |
tperiod_max_idx |
Vector indicating the index (1-based) of the warmest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio26", "cell".
bio26_terra: Solar Radiation of Warmest Period
Description
Calculates solar radiation mean of the period with the highest temperature mean.
Usage
bio26_terra(prad, warmest_period)
Arguments
prad |
spatRaster of solar radiation period means. |
warmest_period |
Vector indicating the index (1-based) of the warmest period. |
Value
spatRaster with "bio26".
bio27_fast: Solar Radiation of Coldest Period
Description
Calculates solar radiation mean of the period with the lowest temperature mean.
Usage
bio27_fast(speriod, tperiod_min_idx, cell)
Arguments
speriod |
Matrix of solar radiation period means (output from 'var_periods'). |
tperiod_min_idx |
Vector indicating the index (1-based) of the coldest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio27", "cell".
bio27_terra: Solar Radiation of Coldest Period
Description
Calculates solar radiation mean of the period with the lowest temperature mean.
Usage
bio27_terra(prad, coldest_period)
Arguments
prad |
spatRaster of solar radiation period means. |
coldest_period |
Vector indicating the index (1-based) of the coldest period. |
Value
spatRaster with "bio27".
bio28_fast: Mean Moisture of Units
Description
Calculates mean moisture across all temporal units.
Usage
bio28_fast(mois, cell)
Arguments
mois |
Matrix of average moisture for each unit. |
cell |
Vector of original cell IDs. |
Value
Matrix with columns: "bio28", "cell".
bio28_terra: Mean Moisture of Units
Description
Calculates mean moisture across all temporal units.
Usage
bio28_terra(mois)
Arguments
mois |
spatRaster of average moisture for each unit. |
Value
spatRaster with "bio28".
bio29_fast: Highest Moisture Unit
Description
Identifies highest moisture unit, potentially using a static index.
Usage
bio29_fast(mois, cell, index_vector = NULL)
Arguments
mois |
Matrix of moisture values for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts mois for that unit. If NULL, finds overall max mois. |
Value
Matrix with "bio29", "cell".
bio29_terra: Highest Moisture Unit
Description
Identifies highest moisture unit, potentially using a static index.
Usage
bio29_terra(mois, high_mois_unit = NULL)
Arguments
mois |
spatRaster of moisture values for each unit. |
Value
spatRaster with "bio29".
bio30_fast: Lowest Moisture Unit
Description
Identifies lowest moisture unit, potentially using a static index.
Usage
bio30_fast(mois, cell, index_vector = NULL)
Arguments
mois |
Matrix of moisture values for each unit. |
cell |
Vector of original cell IDs. |
index_vector |
Optional vector of unit indices (1-based). If provided, extracts mois for that unit. If NULL, finds overall max mois. |
Value
Matrix with "bio30", "cell".
bio30_terra: Lowest Moisture Unit
Description
Identifies lowest moisture unit, potentially using a static index.
Usage
bio30_terra(mois, low_mois_unit = NULL)
Arguments
mois |
spatRaster of moisture values for each unit. |
Value
spatRaster with "bio30".
bio31_fast: Moisture Seasonality (Standard Deviation)
Description
Calculates coefficient of variation in moisture across units.
Usage
bio31_fast(mois, n_units, cell)
Arguments
mois |
Matrix containing moisture values for each unit. |
n_units |
Integer. The total number of temporal units. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio31", "cell".
bio31_terra: Moisture Seasonality (Standard Deviation)
Description
Calculates coefficient of variation in moisture across units.
Usage
bio31_terra(mois)
Arguments
mois |
Matrix containing moisture values for each unit. |
Value
spatRaster with "bio31".
bio32_fast: Moisture of the Most Moist Period
Description
Calculates moisture mean of the most moist period.
Usage
bio32_fast(speriod, speriod_max_idx, cell)
Arguments
speriod |
Matrix of moisture period means (output from 'var_periods'). |
speriod_max_idx |
Vector indicating the index (1-based) of the most moist period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio32", "cell".
bio32_terra: Moisture of the Most Moist Period
Description
Calculates moisture mean of the most moist period.
Usage
bio32_terra(pmois, high_mois_period)
Arguments
pmois |
spatRaster of moisture period means. |
high_mois_period |
Vector indicating the index (1-based) of the most moist period. |
Value
spatRaster with "bio32".
bio33_fast: Moisture of the Least Moist Period
Description
Calculates moisture mean of the least moist period.
Usage
bio33_fast(speriod, speriod_min_idx, cell)
Arguments
speriod |
Matrix of moisture period means (output from 'var_periods'). |
speriod_min_idx |
Vector indicating the index (1-based) of the least moist period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio33", "cell".
bio33_terra: Moisture of the Least Moist Period
Description
Calculates moisture mean of the least moist period.
Usage
bio33_terra(pmois, low_mois_period)
Arguments
pmois |
spatRaster of moisture period means. |
low_mois_period |
Vector indicating the index (1-based) of the least moist period. |
Value
spatRaster with "bio33".
bio34_fast: Moisture of Warmest Period
Description
Calculates moisture mean of the period with the highest temperature mean.
Usage
bio34_fast(speriod, tperiod_max_idx, cell)
Arguments
speriod |
Matrix of moisture period means (output from 'var_periods'). |
tperiod_max_idx |
Vector indicating the index (1-based) of the warmest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio34", "cell".
bio34_terra: Moisture of Warmest Period
Description
Calculates moisture mean of the period with the highest temperature mean.
Usage
bio34_terra(pmois, warmest_period)
Arguments
pmois |
spatRaster of moisture period means. |
warmest_period |
Vector indicating the index (1-based) of the warmest period. |
Value
spatRaster with "bio34".
bio35_fast: Moisture of Coldest Period
Description
Calculates moisture mean of the period with the lowest temperature mean.
Usage
bio35_fast(speriod, tperiod_min_idx, cell)
Arguments
speriod |
Matrix of moisture period means (output from 'var_periods'). |
tperiod_min_idx |
Vector indicating the index (1-based) of the coldest period. |
cell |
Vector of original cell IDs. |
Value
Matrix with "bio35", "cell".
bio35_terra: Moisture of Coldest Period
Description
Calculates moisture mean of the period with the lowest temperature mean.
Usage
bio35_terra(pmois, coldest_period)
Arguments
pmois |
spatRaster of moisture period means. |
coldest_period |
Vector indicating the index (1-based) of the coldest period. |
Value
spatRaster with "bio35".
Tiled, Out-of-Core Bioclimatic Variable Calculation
Description
Internal function to calculate bioclimatic variables for very large datasets by processing them in tiles. It reads data from file paths using 'exactextractr' and performs calculations with 'Rfast'.
Usage
bioclim_fast(
bios,
n_units,
tmin_path = NULL,
tmax_path = NULL,
prcp_path = NULL,
tavg_path = NULL,
srad_path = NULL,
mois_path = NULL,
period_length = 3,
circular = TRUE,
user_region = NULL,
tile_degrees = 5,
output_dir = tempdir(),
...
)
Arguments
bios |
Numeric vector of variables to compute. |
n_units |
Integer, number of layers per variable. |
period_length |
Integer, length of a calculation period. |
circular |
Logical, whether to wrap periods. |
user_region |
An 'sf' or 'SpatVector' object for the area of interest. |
tile_degrees |
Numeric, size of processing tiles. |
output_dir |
Character, path for temporary files. |
... |
File paths for climate variables (e.g., 'tmin_path') and static indices (e.g., 'warmest_period_path'). |
Value
Character string: Path to the temporary directory containing intermediate '.qs' files, to be used by an assembly function.
See Also
The user-facing wrapper function 'derive_bioclim()'.
In-Memory Bioclimatic Variable Calculation
Description
Internal function to calculate bioclimatic variables using 'terra' functions. It is designed for datasets that can fit into RAM.
Usage
bioclim_terra(
bios,
tmin = NULL,
tmax = NULL,
tavg = NULL,
prcp = NULL,
srad = NULL,
mois = NULL,
period_length = 3,
circular = TRUE,
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE,
output_dir = tempdir(),
...
)
Arguments
bios |
Numeric vector of variables to compute. |
period_length |
Integer, length of a calculation period. |
circular |
Logical, whether to wrap periods. |
gdal_opt |
Character vector of GDAL options for writing. |
overwrite |
Logical, whether to overwrite existing files. |
output_dir |
Character, path to save final rasters. |
... |
'SpatRaster' objects for climate variables (e.g., 'tmin', 'tmax') and static indices (e.g., 'warmest_period'). |
Value
A 'terra::SpatRaster' object pointing to the newly created files.
See Also
The user-facing wrapper function 'derive_bioclim()'.
Print Bioclimatic Variable Names
Description
This function prints the names of bioclimatic variables based on the specified indices.
Usage
bionames(bios = 1:35)
Arguments
bios |
Numeric vector indicating the indices of bioclimatic variables to print. Default is 1:35, which prints all variable names. |
Value
None. Prints the names of the selected bioclimatic variables to the console.
Examples
bionames() # Print all bioclimatic variable names
bionames(c(1, 5, 12)) # Print names for variables 1, 5, and 12
Calculate Averages for SpatRasters
Description
Calculates temporal averages for a multi-layer SpatRaster. This function serves as a smart wrapper, automatically selecting between an in-memory ('terra') or out-of-core ('tiled') workflow based on data size.
Usage
calculate_average(
x,
index,
output_names = NULL,
output_dir = tempdir(),
user_region = NULL,
method = c("auto", "tiled", "terra"),
tile_degrees = 5,
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE
)
Arguments
x |
A 'terra::SpatRaster' object with multiple layers representing a time series. |
index |
A numeric or integer vector defining the grouping for aggregation. Its length must equal the number of layers in 'x'. For example, to average 360 monthly layers into 12 monthly means, 'index' would be 'rep(1:12, 30)'. |
output_names |
A character vector of names for the output layers. Its length must equal the number of unique groups in 'index'. If 'NULL', names like "avg_unit_1" are generated. |
output_dir |
The directory where the final averaged raster layers will be saved as GeoTIFF files. |
user_region |
(Optional) An 'sf' or 'terra::SpatVector' object for clipping. |
method |
The processing method: "auto", "tiled", or "terra". |
tile_degrees |
(Tiled method only) The approximate size of processing tiles. |
gdal_opt |
(Optional) GDAL creation options for the output GeoTIFFs. |
overwrite |
Logical. If 'FALSE' (default), stops if output files exist. |
Value
A 'terra::SpatRaster' object pointing to the newly created files.
Calculate Rolling Temporal Averages for SpatRasters
Description
Calculates temporal summaries for each time unit over a moving window of cycles. This function is designed for time series where fundamental time **units** (e.g., months) are grouped into repeating **cycles** (e.g., years).
Usage
calculate_roll(
x,
window_size,
freq = 12,
step = 1,
fun = "mean",
name_template = "{prefix}_w{start_window}-{end_window}_u{idx_unit}",
output_prefix = "output",
output_dir = tempdir(),
user_region = NULL,
method = c("auto", "tiled", "terra"),
tile_degrees = 5,
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE
)
Arguments
x |
A 'terra::SpatRaster' object where each layer represents a time **unit**. |
window_size |
Integer. The size of the moving window, measured in the number of **cycles**. For example, if the data cycle is annual ('freq = 12'), a 'window_size' of 20 represents a 20-year window. |
freq |
Integer. The number of time **units** (layers) that constitute one complete **cycle**. Common examples: 12 for monthly units in a yearly cycle, or 24 for hourly units in a daily cycle. |
step |
Integer. The number of **cycles** to slide the window by for each iteration. Default is 1. |
fun |
Character. The name of the summary function (e.g., "mean"). Default is "mean". |
name_template |
A character string defining the template for output filenames, using 'glue' syntax. Default: '"{prefix}_w{start_window}-{end_window}_u{idx_unit}"'. Available placeholders are:
|
output_prefix |
A character string for output filenames. Default is "output". |
output_dir |
Directory to save the final GeoTIFF files. |
user_region |
(Optional) An 'sf' or 'terra::SpatVector' for clipping. |
method |
Processing method: "auto", "tiled", or "terra". |
tile_degrees |
(Tiled method only) Approximate size of processing tiles. |
gdal_opt |
(Optional) GDAL creation options for GeoTIFFs. |
overwrite |
Logical. If 'FALSE' (default), stops if output files exist. |
Value
A 'terra::SpatRaster' object pointing to the newly created files.
Standardize Environmental Variable Input Format
Description
Converts data frames, matrices, or vectors into a consistent matrix format with preserved column/row names for downstream processing.
Usage
check_evar(evar)
Arguments
evar |
Input environmental variable data. Can be: - data.frame: Converted to matrix - vector: Transposed to row matrix - matrix: Preserved with names checked |
Value
Matrix with column names preserved. If input was a vector, returns 1-row matrix with vector names as column names.
Validate Climate Input Rasters
Description
Performs rigorous checks on a set of climate raster files to ensure they are suitable for bioclimatic variable calculation.
Usage
check_rasters(..., check_nas = TRUE)
Arguments
... |
Named arguments providing character vectors of file paths for each climate variable (e.g., 'tmin_files = c(...)', 'prcp_files = c(...)'). |
check_nas |
Logical. If 'TRUE' (the default), perform the potentially slow check for mismatched NA values. If 'FALSE', only check for geometry. |
Details
This function checks for two main sources of error: 1. **Geometric Inconsistency**: Ensures all input rasters share the exact same coordinate reference system (CRS), extent, and resolution. 2. **NA Mismatch**: Checks if the pattern of NA values is consistent across all layers of all provided climate variables. Mismatched NAs can lead to silent errors in calculations. This check can be time-consuming for very large rasters.
Value
A list containing a summary of the validation:
`is_valid` |
A single logical value: 'TRUE' if all checks pass, 'FALSE' otherwise. |
`geom_report` |
A message detailing the result of the geometry check. |
`na_report` |
A message detailing the result of the NA check. |
`mismatch_raster` |
If 'check_nas=TRUE' and mismatches are found, a 'SpatRaster' where non-zero values indicate pixels with inconsistent NAs. |
Calculate Sliding Periods for Temporal Analysis
Description
Defines sliding periods of a specified length for temporal calculations, handling wrap-around cases for circular data.
Usage
compute_periods(n_units, period_length, circular = TRUE)
Arguments
n_units |
Integer. The total number of temporal units (layers). |
period_length |
Integer. The number of consecutive units in each period. |
circular |
Logical. If TRUE, allows periods to wrap around. |
Value
List where each element contains 'period_length' consecutive unit indices.
Create an Inverse Cell ID Translation Function
Description
Generates a function to translate cell IDs from a source raster grid to a target raster grid, considering potential offsets and different dimensions. Handles cases where the target grid is a subset (e.g., cropped/masked) of the source grid.
Usage
define_translate(ncol_src, ncol_tgt, row_offset, col_offset)
Arguments
ncol_src |
Integer. Number of columns in the source raster. |
ncol_tgt |
Integer. Number of columns in the target raster. |
row_offset |
Integer. Row offset of the target grid's top-left corner relative to the source grid's top-left corner (0-based). |
col_offset |
Integer. Column offset of the target grid's top-left corner relative to the source grid's top-left corner (0-based). |
Value
A function that takes a vector of source cell IDs ('cell_src') and returns a vector of corresponding target cell IDs. Cells falling outside the target grid bounds will have 'NA_integer_' as their target ID.
Derive Comprehensive Bioclimatic Variables
Description
Calculates up to 35 bioclimatic variables from average monthly climate SpatRasters (or other temporal units). This function serves as a smart wrapper that automatically selects the most efficient processing workflow (in-memory vs. tiled) based on data size and user-defined region of interest.
Usage
derive_bioclim(
bios,
tmin = NULL,
tmax = NULL,
prcp = NULL,
tavg = NULL,
srad = NULL,
mois = NULL,
output_dir = tempdir(),
period_length = 3,
circular = TRUE,
user_region = NULL,
method = c("auto", "tiled", "terra"),
tile_degrees = 5,
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE,
...
)
Arguments
bios |
Numeric vector specifying which bioclimatic variables (1-35) to compute. |
tmin , tmax , prcp , tavg , srad , mois |
(Optional) 'terra::SpatRaster' objects containing the climate data for each temporal unit (e.g., 12 monthly layers). All provided rasters must have the same geometry and number of layers. |
output_dir |
The directory where the final bioclimatic variable rasters will be saved. The directory will be created if it does not exist. The default is temporal directory created by 'tempdir'. |
period_length |
Integer. The number of temporal units (e.g., months) that define a "period" for calculating summary variables like BIO8 (Mean Temp of Wettest Quarter). Defaults to 3, representing quarters for monthly data. |
circular |
Logical. If 'TRUE' (the default), period calculations will wrap around the beginning and end of the time series (e.g., for monthly data, Dec-Jan-Feb is considered a valid period). |
user_region |
(Optional) An 'sf' or 'terra::SpatVector' object defining the area of interest. If provided, all calculations will be clipped to this region. |
method |
The processing method. See Details for more information. |
tile_degrees |
(Tiled method only) The approximate size of processing tiles in degrees. Ignored if the 'terra' workflow is used. |
gdal_opt |
(Optional) A character vector of GDAL creation options for the output GeoTIFF files. Controls compression, threading, etc. |
overwrite |
(Optional) Logical. If 'FALSE' (the default), the function will stop immediately if any target output files already exist. |
... |
Additional arguments, primarily for passing static index rasters. See the "Static Indices" section for details. |
Details
This function unifies two processing backends. The 'method' argument controls which is used:
'"auto"': (Default) Intelligently chooses between "terra" and "tiled" based on estimated memory requirements.
'"terra"': Forces the fast, in-memory workflow. May fail on very large datasets.
'"tiled"': Forces the memory-safe, out-of-core workflow. Ideal for very large datasets. Requires that the input SpatRasters point to files on disk.
Period-based variables (e.g., BIO8, BIO10) are calculated using a moving window defined by 'period_length'.
Value
An SpatRaster with 35 bioclimatic variables or a subset of them:
- bio01
Mean Temperature of Units
- bio02
Mean Diurnal Range
- bio03
Isothermality
- bio04
Temperature Seasonality
- bio05
Max Temperature of Warmest Unit
- bio06
Min Temperature of Coldest Unit
- bio07
Temperature Range of Units
- bio08
Mean Temperature of Wettest Period
- bio09
Mean Temperature of Driest Period
- bio10
Mean Temperature of Warmest Period
- bio11
Mean Temperature of Coldest Period
- bio12
Precipitation Sum
- bio13
Precipitation of Wettest Unit
- bio14
Precipitation of Driest Unit
- bio15
Precipitation Seasonality
- bio16
Precipitation of Wettest Period
- bio17
Precipitation of Driest Period
- bio18
Precipitation of Warmest Period
- bio19
Precipitation of Coldest Period
- bio20
Mean Radiation of Units
- bio21
Highest Radiation Unit
- bio22
Lowest Radiation Unit
- bio23
Radiation Seasonality
- bio24
Radiation of Wettest Period
- bio25
Radiation of Driest Period
- bio26
Radiation of Warmest Period
- bio27
Radiation of Coldest Period
- bio28*
Mean Moisture Content Of Units
- bio29*
Highest Moisture Content Unit
- bio30*
Lowest Moisture Content Unit
- bio31*
Moisture Content Seasonality
- bio32*
Mean Moisture Content of Most Moist Period
- bio33*
Mean Moisture Content of Least Moist Period
- bio34*
Mean Moisture Content of Warmest Period
- bio35*
Mean Moisture Content of Coldest Period
Static Indices
For advanced use cases, such as time-series analysis or defining specific seasons, you can provide pre-calculated index rasters to override the dynamic calculations. These are passed as named 'SpatRaster' objects via the '...' argument (e.g., 'warmest_period = my_warmest_idx_rast'). The wrapper function automatically handles passing them to the appropriate workflow.
When using the "tiled" workflow, these static index rasters **must** be file-backed (i.e., not held entirely in memory). Supported static indices include:
'warmest_unit', 'coldest_unit', 'wettest_unit', 'driest_unit'
'high_rad_unit', 'low_rad_unit', 'high_mois_unit', 'low_mois_unit'
'warmest_period', 'coldest_period', 'wettest_period', 'driest_period'
'high_mois_period', 'low_mois_period'
Note
*The original moisture variables proposed in the ANUCLIM manual are based on the Moisture Index (MI). However, this function allows users to calculate moisture-based bioclimatic variables using other units of moisture as inputs, offering greater flexibility in input data usage.
References
O’Donnell, M. S., & Ignizio, D. A. (2012). Bioclimatic predictors for supporting ecological applications in the conterminous United States. ANUCLIM 6.1 User Guide. Centre for Resource and Environmental Studies, The Australian National University.
See Also
'validate_climate_inputs()' to check data integrity before processing.
Examples
# This is a conceptual example, requires data setup
## Not run:
# Assume tmin_rast, tmax_rast, prcp_rast are 12-layer SpatRasters
bioclim_vars <- derive_bioclim(
bios = 1:19,
tmin = tmin_rast,
tmax = tmax_rast,
prcp = prcp_rast,
output_dir = "./bioclim_output",
overwrite = TRUE
)
plot(bioclim_vars[[c("bio01", "bio12")]])
## End(Not run)
Derive Custom Summary Statistics from Climate Variables
Description
Calculates a wide range of custom summary statistics for a primary climate variable, with options for interactions with a second variable. This function serves as a smart wrapper that automatically selects the most efficient processing workflow (in-memory vs. tiled).
Usage
derive_statistics(
variable,
stats = c("mean", "max", "min"),
inter_variable = NULL,
inter_stats = NULL,
prefix_variable = "var",
suffix_inter_max = "inter_high",
suffix_inter_min = "inter_low",
output_dir = tempdir(),
period_length = 3,
period_stats = "mean",
circular = TRUE,
user_region = NULL,
method = c("auto", "tiled", "terra"),
tile_degrees = 5,
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE,
...
)
Arguments
variable |
A 'terra::SpatRaster' object for the primary variable. |
stats |
A character vector of statistics to compute for the primary variable. Supported: '"mean"', '"max"', '"min"', '"sum"', '"stdev"', '"cv_cli"', '"max_period"', '"min_period"'. |
inter_variable |
(Optional) A 'terra::SpatRaster' for an interactive variable. |
inter_stats |
(Optional) A character vector of interactive statistics to compute. Requires 'inter_variable'. Supported: '"max_inter"', '"min_inter"'. |
prefix_variable |
A character string used as the prefix for all output file names (e.g., 'prefix_variable = "wind"' results in "wind_mean.tif", "wind_max.tif"). |
suffix_inter_max |
Character. Suffix for the "max_inter" statistic name. Default: "inter_high". |
suffix_inter_min |
Character. Suffix for the "min_inter" statistic name. Default: "inter_low". |
output_dir |
The directory where the final summary rasters will be saved. |
period_length |
Integer. The number of temporal units defining a "period". Default: 3. |
period_stats |
Character. The statistic ("mean" or "sum") to summarize data over each period. Default: "mean". |
circular |
Logical. If 'TRUE' (the default), period calculations wrap around. |
user_region |
(Optional) An 'sf' or 'terra::SpatVector' object defining the area of interest. |
method |
The processing method. See Details for more information. |
tile_degrees |
(Tiled method only) The approximate size of processing tiles. |
gdal_opt |
(Optional) A character vector of GDAL creation options for the output GeoTIFF files. |
overwrite |
(Optional) Logical. If 'FALSE' (the default), the function will stop if output files already exist. |
... |
Additional arguments, primarily for passing static index 'SpatRaster' objects. See the "Static Indices" section. |
Details
This function provides a flexible alternative to 'derive_bioclim()' for any multi-layer climate variable (e.g., wind speed, humidity). It unifies two processing backends, controlled by the 'method' argument:
'"auto"': (Default) Intelligently chooses between "terra" and "tiled".
'"terra"': Forces the fast, in-memory workflow.
'"tiled"': Forces the memory-safe, out-of-core workflow. Requires that all input SpatRasters point to files on disk.
Value
A 'terra::SpatRaster' object pointing to the newly created summary rasters.
Static Indices
For advanced control, provide pre-calculated index rasters as named 'SpatRaster' objects via the '...' argument (e.g., 'max_unit = max_idx_rast'). Supported indices: 'max_unit', 'min_unit', 'max_period', 'min_period', 'max_interactive', 'min_interactive'.
Windows
Description
Windows
Usage
get_window(x, period, circular)
Arguments
x |
spatRaster |
period |
Length of period. Default is three. If you are using months. It will be a quarter. |
circular |
logical Include first month/weeks? |
Tiled, Out-of-Core Rolling Time Series Averaging (Internal) - CORRECTED
Description
Tiled, Out-of-Core Rolling Time Series Averaging (Internal) - CORRECTED
Usage
roll_fast(
paths,
window_size,
freq,
step,
fun,
output_names_list,
user_region,
tile_degrees,
output_dir
)
In-Memory Rolling Time Series Averaging (Internal)
Description
In-Memory Rolling Time Series Averaging (Internal)
Usage
roll_terra(
x,
window_size,
freq,
step,
fun,
output_names_list,
output_dir,
gdal_opt,
overwrite
)
Tiled, Out-of-Core Custom Variable Summarization
Description
Internal function to calculate custom summary statistics for very large datasets by processing them in tiles.
Usage
stats_fast(
variable_path,
n_units,
stats = c("mean", "max", "min"),
period_length = 3,
period_stats = "mean",
circular = TRUE,
inter_variable_path = NULL,
inter_stats = NULL,
max_unit_path = NULL,
min_unit_path = NULL,
max_period_path = NULL,
min_period_path = NULL,
max_interactive_path = NULL,
min_interactive_path = NULL,
prefix_variable = "var",
suffix_inter_max = "inter_high",
suffix_inter_min = "inter_low",
user_region = NULL,
tile_degrees = 5,
output_dir = tempdir(),
write_raw_vars = FALSE,
...
)
Arguments
variable_path |
Path to primary variable rasters. |
n_units |
Integer, number of layers per variable. |
stats |
Character vector of stats to compute. |
prefix_variable |
Character, prefix for output files. |
... |
Other arguments including inter_variable_path, period_length, circular, static index paths, etc. |
Value
Character string: Path to the temporary directory containing intermediate '.qs' files.
See Also
The user-facing wrapper function 'derive_statistics()'.
In-Memory Custom Variable Summarization
Description
Internal function to calculate custom summary statistics using 'terra' functions. Designed for datasets that fit into RAM.
Usage
stats_terra(
variable,
stats = c("mean", "max", "min", "cv_cli", "max_period", "min_period"),
period_length = 3,
period_stats = "mean",
circular = TRUE,
inter_variable = NULL,
inter_stats = c("max_inter", "min_inter"),
max_unit = NULL,
min_unit = NULL,
max_period = NULL,
min_period = NULL,
max_interactive = NULL,
min_interactive = NULL,
prefix_variable = "var",
suffix_inter_max = "inter_high",
suffix_inter_min = "inter_low",
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE,
output_dir = tempdir(),
...
)
Arguments
variable |
A SpatRaster for the primary variable. |
stats |
Character vector of stats to compute. |
prefix_variable |
Character, prefix for output layer names. |
... |
Other arguments including inter_variable, period_length, circular, static index SpatRasters, etc. |
Value
A 'terra::SpatRaster' object containing the calculated summary layers.
See Also
The user-facing wrapper function 'derived_statistics()'.
Calculate Temporal Period Aggregates
Description
Computes aggregates (sums or mean) over defined temporal periods and identifies min/max periods.
Usage
var_periods(variable, periodos, n_units, period_length, stat)
Arguments
variable |
Matrix of temporal values (rows=pixels/cells, cols=units). |
periodos |
List of unit groupings (output from compute_periods). |
n_units |
Integer. Total number of temporal units. |
period_length |
Integer. Length of each period. |
stat |
Character. Either '"mean"' or '"sum"', specifying whether to calculate the average or total |
Value
Matrix with period sums ('num_periods' columns named "period_X"), "min_idx", and "max_idx" columns.
Export Bioclimatic Variables to GeoTIFF
Description
Assembles intermediate '.qs' files into a full vector in memory, performs cell ID mapping if necessary, and writes final GeoTIFF rasters.
Usage
write_layers(
input_dir,
output_dir,
file_pattern = "bio",
gdal_opt = c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS"),
overwrite = FALSE
)
Arguments
input_dir |
Character string. Path to directory with intermediate '.qs' files and 'template_info.qs' |
output_dir |
Character string. Path for the final GeoTIFF files. |
file_pattern |
Character string. A prefix or base pattern to identify the groups of '.qs' files. For example, if files are "bio01_1.qs", "bio01_2.qs", "bio02_1.qs", etc., 'file_pattern' would be "bio". If files are "var_mean_1.qs", "var_sum_1.qs", etc., 'file_pattern' could be "var". The function will attempt to extract the full variable name (e.g., "bio01", "var_mean") from the filenames. Default is "bio". |
gdal_opt |
Character vector. GDAL creation options for the output GeoTIFF files. These options control compression, threading, and other advanced features. See the GDAL documentation for a full list of options for the GeoTIFF driver. The default is 'c("COMPRESS=DEFLATE", "PREDICTOR=3", "NUM_THREADS=ALL_CPUS")', which provides good, lossless compression. To disable compression, use 'NULL'. |
overwrite |
Logical. If 'TRUE', any existing GeoTIFF files in the 'output_dir' with the same name will be overwritten. If 'FALSE' (the default), the function will throw an error if it attempts to write to a file that already exists, which is a safety measure to prevent accidental data loss. |
Value
None. Writes GeoTIFF files to 'output_dir'.
Author(s)
Luis Osorio-Olvera, Gonzalo E. Pinilla-Buitrago