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

Description Usage Arguments Details Value Examples

View source: R/senFolderToVar.R

Description

senFolderToVar computes a remote sensing index from the spectral bands of a time series of Sentinel-2 images. The images are specified by the path to the folder that stores the imagery (resulting from the senMosaic 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
10
senFolderToVar(
  src,
  AppRoot,
  fun,
  getStack = FALSE,
  overwrite = FALSE,
  verbose = FALSE,
  resbands = c("10m", "20m", "60m"),
  ...
)

Arguments

src

the path to the folder with the Sentinel-2 multispectral images.

AppRoot

directory where the outcoming time series is saved.

fun

a function that computes the remote sensing index.

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.

resbands

the resolution of the image being used to compute index, when the imagery comes from the Senintel-2 "S2MSI2A" product. By default, all resolutions (10m, 20m, and 60m) are used.

...

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 senMosaic. 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 Sentinel-2 images
senDownSearch(startDate = as.Date("2018210","%Y%j"),
              endDate = as.Date("2018218","%Y%j"),
              platform = "Sentinel-2",
              extent = ex.navarre,
              product = "S2MSI1C",
              pathrow = c("R094"),
              username = "username",
              password = "password",
              AppRoot = wdir)
# folder with the unzipped images from Sentinel-2
wdir.sen <- file.path(wdir,"Sentinel-2")
wdir.sen.unzip <- file.path(wdir.sen, "unzip")
# mosaic the Sentinel-2 images
senMosaic(wdir.sen.unzip,
          AppRoot = wdir.sen,
          gutils = TRUE,
          out.name = "Navarre")
# path to the folder with the mosaicked images
wdir.sen.navarre <- file.path(wdir.sen, "Navarre")
wdir.sen.var <- file.path(wdir.sen.navarre, "Navarre_Variables")
dir.create(wdir.sen.var)
# generate EVI images of Navarre
senFolderToVar(wdir.sen.navarre,
               fun = varEVI,
               resbands = c("60m"),
               AppRoot = wdir.sen.var)
               
files.sen.evi <- list.files(file.path(wdir.sen.var,"EVI"),
                            pattern = "\\.tif$",
                            full.names = TRUE,
                            recursive = TRUE)

img.sen.evi <- lapply(files.sen.evi, raster)
spplot(img.sen.evi[[1]])

## End(Not run)

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