ls7FolderToVar: Compute a remote sensing index from a time series of...

Description Usage Arguments Details Value Examples

View source: R/ls7FolderToVar.R

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 of the remote sensing index.

Usage

1
2
3
4
5
6
7
8
9
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.

  • dates a vector with the capturing dates being considered for mosaicking. If not supplied, all dates are mosaicked.

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 “var” (varNDVI, varEVI, etc.). Custom functions can also be implemented. Caution! It is mandatory to use level-2 products to get accurate derived variables.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
## Not run: 
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
# download Landsat-7 images
lsDownSearch(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 = wdir)
# folder with the Landsat-7 untared images 
wdir.ls7 <-file.path(wdir,"Landsat7")
wdir.ls7.untar <- file.path(wdir.ls7, "untar")
# mosaic the Landsat-7 images
lsMosaic(wdir.ls7.untar,
         AppRoot = wdir.ls7,
         out.name = "Navarre",
         extent = ex.navarre,
         gutils = TRUE)
# folder with the mosaicked images
wdir.ls7.navarre <- file.path(wdir.ls7, "Navarre")
# generate NDVI images of Navarre
wdir.ls7.var <- file.path(wdir.ls7, "Navarre_Variables")
dir.create(wdir.ls7.var)
ls7FolderToVar(wdir.ls7.navarre,
               fun = varNDVI,
               AppRoot = wdir.ls7.var,
               overwrite = TRUE)
               
files.ls7.ndvi <- list.files(file.path(wdir.ls7.var,"NDVI"),
                             pattern = "\\.tif$",
                             full.names = TRUE,
                             recursive = TRUE)
img.ls7.ndvi <- raster(files.ls7.ndvi[1])
spplot(img.ls7.ndvi)

## End(Not run)

RGISTools documentation built on July 2, 2020, 3:58 a.m.