Learn R Programming

RGISTools (version 0.9.7)

ls7FolderToVar: Compute a remote sensing index from a time series of Landsat-7 images

Description

ls7FolderToVar computes a remote sensing index from the spectral bands of a time series of Landsat-7 images. The images are specified by the path to the folder that stores the imagery (resulting from the lsMosaic function). The function returns a RasterStack with the time series of images with the index.

Usage

ls7FolderToVar(src, fun, AppRoot, getStack = FALSE, overwrite = FALSE,
  verbose = FALSE, ...)

Arguments

src

the path to the folder with the Landsat-7 multispectral imagery.

fun

a function that computes the remote sensing index.

AppRoot

the directory of the outcoming time series.

getStack

logical argument. If TRUE, returns the time series as a RasterStack, otherwise the images are saved in the Hard Drive Device (HDD).

overwrite

logical argument. If TRUE, overwrites the existing images with the same name.

verbose

logical argument. If TRUE, the function prints the running steps and warnings.

...

arguments for nested functions.

Value

this function does not return anything, unless getStack = TRUE and then it returns a RasterStack with the time series of with the index.

Details

The function requires the definition of the src and fun arguments. The src is usually the path resulting from lsMosaic. The fun argument can be any function from this package beginning with <U+201C>var<U+201D> (varNDVI, varEVI, etc.). Custom functions can also be implemented.

Examples

Run this code
# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
src <- paste0(tempdir(),"/Path_for_downloading_folder")
print(src)
# download Landsat-7 images
lsDownload(satellite = "ls7",
           username = "username",
           password = "password",
           startDate = as.Date("01-01-2018", "%d-%m-%Y"),
           endDate = as.Date("20-01-2018", "%d-%m-%Y"),
           extent = ex.navarre,
           untar = TRUE,
           AppRoot = src)
# folder with the Landsat-7 untared images 
src.ls7 <-file.path(src,"Landsat7")
tif.src <- file.path(src.ls7, "untar")
# mosaic the Landsat-7 images
lsMosaic(tif.src,
         AppRoot = src.ls7,
         out.name = "Navarre",
         extent = ex.navarre,
         gutils = TRUE)
# folder with the mosaicked images
src2 <- file.path(src.ls7, "Navarre")
# generate NDVI images of Navarre
src3 <- file.path(src.ls7, "Navarre_Variables")
dir.create(src3)
ls7FolderToVar(src2,
               fun = varNDVI,
               AppRoot = src3,
               overwrite = TRUE)
               
flist <- list.files(file.path(src3,"NDVI"),
                    pattern = "\\.tif$",
                    full.names = TRUE,
                    recursive = TRUE)
ras <- raster(flist[1])
spplot(ras)
# }

Run the code above in your browser using DataLab