modFolderToVar: Compute a remote sensing index from a time series of MODIS...

Description Usage Arguments Details Value Examples

View source: R/modFolderToVar.R

Description

modFolderToVar computes a remote sensing index from the spectral bands of a time series of MODIS images. The images are specified by the path to the folder that stores the imagery (resulting from the modMosaic 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
modFolderToVar(
  src,
  AppRoot,
  fun,
  getStack = FALSE,
  overwrite = FALSE,
  verbose = FALSE,
  ...
)

Arguments

src

path to the folder with the MODIS multispectral images.

AppRoot

the directory of the outcoming time series.

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, it 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 modMosaic. 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-gree-blue (RGB) images must be imported afterwards.

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 MOD09 images
modDownSearch(product = "MOD09GA",
              startDate = as.Date("01-01-2018", "%d-%m-%Y"),
              endDate = as.Date("03-01-2018", "%d-%m-%Y"),
              username = "username",
              password = "password",
              AppRoot = wdir, # output folder for tif images
              extract.tif = TRUE, 
              collection = 6,
              extent = ex.navarre)
# assign wdir.mod as the output folder from modMosaic
wdir.mod <- file.path(wdir, "Modis", "MOD09GA") # output directory
wdir.mod.tif <- file.path(wdir.mod, "tif") # input directory
# mosaic the MODIS images
modMosaic(wdir.mod.tif,
          AppRoot = wdir.mod,
          out.name = "Navarre")
# path to the folder with the mosaicked images
wdir.mod.navarre <- file.path(wdir.mod, "Navarre")
# generate NDVI images of Navarre
wdir.mod.var <- file.path(wdir.mod, "Variables")
dir.create(wdir.mod.var)
modFolderToVar(src = wdir.mod.navarre,
               fun = varEVI,
               scfun = getRGISToolsOpt("MOD09SCL"),
               AppRoot = wdir.mod.var,
               overwrite = TRUE)
# import mosaicked images (.tif) to the environment in `R'
files.mod.evi <- list.files(file.path(wdir.mod.var,"EVI"),
                            pattern = "\\.tif$",
                            full.names = TRUE,
                            recursive = TRUE)

img.mod.evi <- lapply(files.mod.evi,raster)
spplot(img.mod.evi[[1]],at=seq(-1,2.5))

## End(Not run)

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