calcIndices: Calculate spectral indices from multispectral data

Description Usage Arguments Details Value See Also Examples

View source: R/calcIndices.R

Description

Calculate spectral indices (e.g. NDVI, tasseled cap coefficients etc.) from multispectral data. Calculations are based on the functions spectralIndices and tasseledCap. Refer to the documentation of these functions for more details.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
calcIndices(
  x,
  indices = "NDVI",
  sat = NULL,
  blue = NULL,
  green = NULL,
  red = NULL,
  nir = NULL,
  swir1 = NULL,
  swir2 = NULL,
  swir3 = NULL,
  coefs = list(L = 0.5, G = 2.5, L_evi = 1, C1 = 6, C2 = 7.5, s = 1, swir2ccc = NULL,
    swir2coc = NULL),
  filename = "",
  par = FALSE,
  threads = 2,
  m = 2,
  progress = TRUE,
  ...
)

Arguments

x

Raster* or SpatialPointsDataFrame object or list of Raster* or SpatialPointsDataFrame objects.

indices

Character vector indicating Which indices are calculated. Tasseled Cap indices are abbreviated as TCB, TCW, TCG, TCA, TCD. For a list of other supported indices see spectralIndices

sat

Character. If calculating tasseled cap indices, name of the sensor needs to be provided. One of: c("Landsat4TM", "Landsat5TM", "Landsat7ETM", "Landsat8OLI", "MODIS", "QuickBird", "Spot5", "RapidEye"). See tasseledCap.

blue

Integer. Blue band.

green

Integer. Green band.

red

Integer. Red band.

nir

Integer. Near infrared band (700-1100 nm).

swir1

temporarily deprecated

swir2

Integer. Shortwave infrared band (1400-1800 nm)

swir3

Integer. Shortwave infrared band (2000-2500 nm)

coefs

Coefficients necessary to calculate some of the spectral indices (e.g. EVI). See spectralIndices.

filename

Character. Output file name including path to directory and eventually extension. If x is a list, filename must be a vector of characters with one file name for each element of x. Default is "" (output not written to disk).

par

Logical. Should the function be executed on parallel threads

threads

Number of parallel threads used if par = TRUE

m

tuning parameter to determine how many blocks will be used (m blocks will be processed by each cluster)

progress

Logical. If TRUE (default) a progress bar is displayed when using parallel processing.

...

Other arguments passed to writeRaster or writeOGR.

Details

If x is a Raster* or list of Raster* objects, each layer should be one of the spectral bands used to calculate the indices. If x is a SpatialPointsDataFrame or list of spatialPointsDataFrame, each column should be a spectral band. When calculating tasseledCap indices, bands should be provided in a specific order specified in tasseledCap.

Tasseled Cap Angle (TCA) and Distance (TCD) are calculated from greenness (TCG) and brightness (TCB) as follows:

TCA = \arctan(\frac{TCG}{TCB})

TCD = √{TCB^{2} + TCG^{2}}

If x is a list of Raster* objects, the processing can be parallelized using cluster. In that case the user has to set par = TRUE and provide the number of parallel threads threads. You can control how many blocks will be processed by each thread by setting m (see cluster).

Value

Raster* or SpatialPointsDataFrame object or list of Raster* or SpatialPointsDataFrame objects.

See Also

spectralIndices, tasseledCap, cluster

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(raster)

# Open Landsat BAP image
BAP_2006 <- stack(system.file("extdata/examples/Landsat_BAP_2006.tif",package =
                                "foster"))

# Calculate NDVI
VI_2006 <- calcIndices(BAP_2006,
                       indices = "NDVI",
                       red=3,
                       nir=4)

mqueinnec/foster documentation built on March 28, 2021, 4:27 p.m.