Learn R Programming

climodr (version 1.0.0)

calc.indices: Calculate spectral indices

Description

Calculates a set of spectral indices to have more predictor variables available when further modeling.

Usage

calc.indices(
  envrmt = .GlobalEnv$envrmt,
  vi = "all",
  bands = c("blue", "green", "red", "nir", "nirb", "re1", "re2", "re3", "swir1", "swir2"),
  overwrite = FALSE
)

Value

SpatRaster-Stack

Arguments

envrmt

variable name of your envrmt list created using climodr's `envi.create` function. Default = envrmt.

vi

Character. Either "all" or vector containing the preferred spectral indices. See 'Details' for more information.

bands

Character. Vector with lenght(bands) = 10. Contains the names of the bands in the Raster Stack. If bands from the *Usage* example vector dont exist, use "NA" in their position. See 'Details' for more information.

overwrite

logical. Argument passed down from `terra`-package. Overwrite existing files?

See Also

`crop.all`, `fin.csv`

Examples

Run this code
#create climodr environment and allow terra-functions to use 70% of RAM
envrmt <- envi.create(proj_path = tempdir(),
                      memfrac = 0.7)

# Load the climodr example data into the current climodr environment
clim.sample(envrmt = envrmt)

# Crop all raster bands
crop.all(envrmt = envrmt,
         method = "MB_Timeseries",
         overwrite = TRUE)

# Calculate Indices from cropped raster bands
calc.indices(envrmt = envrmt,
             vi = "all",
             bands = c("blue", "green", "red",
                       "nir", "nirb",
                       "re1", "re2", "re3",
                       "swir1", "swir2"),
             overwrite = TRUE)

Run the code above in your browser using DataLab