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

Description Usage Arguments Details Value Examples

View source: R/ls8FolderToVar.R

Description

ls8FolderToVar computes a remote sensing index from the spectral bands of a time series of Landsat-8 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 a time series of images of the remote sensing index.

Usage

1
2
3
4
5
6
7
8
9
ls8FolderToVar(
  src,
  fun,
  AppRoot,
  getStack = FALSE,
  overwrite = FALSE,
  verbose = FALSE,
  ...
)

Arguments

src

path to the folder with the Landsat-8 multispectral image.

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 of images 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. If fun = varRGB, then the argument getStack must be equal to FALSE and the red-green-blue (RGB) images must be imported afterwards. 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
43
## 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-8 images
lsDownSearch(satellite = "ls8",
             username = "username",
             password = "password",
             startDate = as.Date("01-01-2018","%d-%m-%Y"),
             endDate = as.Date("18-01-2018","%d-%m-%Y"),
             pathrow = list(c(200, 31), c(200, 30)),
             untar = TRUE,
             AppRoot = wdir)
# folder with the Landsat-8 untared images
src.ls8 <-file.path(wdir,"Landsat8")
src.ls8.untar <- file.path(src.ls8, "untar")
# mosaic the Landsat-8 images
lsMosaic(src = src.ls8.untar,
         AppRoot = src.ls8,
         out.name = "Navarre",
         extent = ex.navarre,
         gutils = TRUE)
# path to the folder with mosaicked images
src.ls8.navarre <- file.path(src.ls8, "Navarre")
# generate NDVI images of Navarre
src.ls8.var <- file.path(src.ls8, "Navarre_Variables")
dir.create(src.ls8.var)
ls8FolderToVar(src.ls8.navarre,
               fun = varNDVI,
               AppRoot = src.ls8.var,
               overwrite = TRUE)
               
files.ls8.ndvi <- list.files(file.path(src.ls8.var,"NDVI"),
                             pattern = "\\.tif$",
                             full.names = TRUE,
                             recursive = TRUE)

img.ls8.ndvi <- raster(files.ls8.ndvi[1])
spplot(img.ls8.ndvi)

## End(Not run)

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