processLandsat: Wrapper function to process Landsat data

Description Usage Arguments Value Author(s) See Also Examples

Description

Processes a single Landsat scene, from tarball or zip archive (or hdf/tiff if untar is set to FALSE) to vegetation index. Easy to batch using sapply or mclapply for parallel implementation. Data obtained from espi may already contained pre-processed indices layers, in which case they are directly used.

Usage

1
2
processLandsat(x, vi = "ndvi", srdir, outdir, untar = TRUE,
  delete = FALSE, mask = NULL, L = 0.5, ...)

Arguments

x

Character. filename of the tarball or zip archive of the hdf/tiff file.

vi

Character. Vegetation index to be computed or extracted from the archive. Can be either 'ndvi', 'evi', 'savi', 'ndmi'*, 'nbr', 'nbr2'* or 'msavi'*. Indices with * need to be present in the archive. Note that it is also possible to extract single bands using the vi= argument. vi='sr_band1' for instance will extract surface reflectance band 1 from the archive and perform the same pre-processing steps as if it was a vegetation index layer.

srdir

Character. Directory where the tarball should be uncompressed. Can be ommited if untar is set to FALSE

outdir

Character. Directory where the vegetation index rasterLayer should be written.

untar

Logical. Is there a need to untar data, or have they been previously unpacked.

delete

Logical. Should surface reflectance files (hdf/tiff) be deleted after vegetation index calculated? (usefull for disk space management; surface reflectance files are very voluminous and a user may want to keep the Landsat archive in compressed format only)

mask

Character or NULL. The name of the mask to be applied to the bands (e.g.: mask = 'fmask')

L

Numeric. Soil-adjustment factor for SAVI (ignored if vi != 'savi'). L can take on values between 0 and 1, and a default of 0.5 is typically used.

...

Arguments to be passed to sr2vi. Do not specify filename since it is automatically generated

Value

rasterLayer Object also written to file (in outdir) with an automatically generated filename

Author(s)

Loic Dutrieux

See Also

sr2vi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Get list of test data files
dir <- system.file('external', package='bfastSpatial')
list <- list.files(dir, full.names=TRUE)

# Set the location of output and intermediary directories (everything in tmpdir in that case)
srdir <- dirout <- file.path(rasterOptions()$tmpdir, 'bfmspatial')
dir.create(dirout, showWarning=FALSE)
# Generate (or extract, depending on whether the layer is already in the archive or not) NDVI for the first archive file
processLandsat(x=list[1], vi='ndvi', outdir=dirout, srdir=srdir, delete=TRUE, mask='fmask', keep=0, overwrite=TRUE)

# Visualize one of the layers produced
list <- list.files(dirout, pattern=glob2rx('*.grd'), full.names=TRUE)
plot(r <- raster(list[1]))

loicdtx/bfastSpatial documentation built on May 21, 2019, 7:37 a.m.