Learn R Programming

bfastSpatial (version 0.6.2)

timeStack: Creates a time stack of Landsat layers

Description

Creates a stack of Landsat layers, reordering them chronologically

Usage

timeStack(x, pattern = NULL, orderChrono = TRUE, ...)

Arguments

x

character. dir containing the files to be stacked or character list (the files). IN the former case, it is recommended to use the pattern argument

pattern
orderChrono

Logical. Should layers in the output object be orderred chronologically. If set to FALSE, layer order will be alphabetical.

...

Arguments to be passed to writeRaster. If specifying a filename, it is strongly recommended to also set a datatype.

Examples

Run this code
# NOT RUN {
# 1 - Produce individual VI layers (using processLandsatBatch())
# Get the directory where the Landsat archives are stored
dir <- system.file('external', package='bfastSpatial')

# 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)
processLandsatBatch(x=dir, pattern=glob2rx('*.zip'), outdir=dirout, srdir=srdir, delete=TRUE, vi='ndvi', mask='fmask', keep=0, overwrite=TRUE)

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


# Stack the layers
stackName <- file.path(dirout, 'stack/stackTest.grd')
dir.create(file.path(dirout, 'stack'))
s <- timeStack(x=dirout, pattern=glob2rx('*.grd'), filename=stackName, datatype='INT2S')

plot(s)
# }

Run the code above in your browser using DataLab