Launching MODIStsp using a saved “Options file”

MODIStsp can be launched in non-interactive mode within an R session by setting the optional GUI parameter to FALSE, and the Options_File parameter to the path of a previously saved JSON Options file. This allows to exploit MODIStsp functionalities within generic “R” processing scripts:



## [1] "EVI"         "NDVI"        "QA_usef"     "Time_Series"
list.files(file.path(out_fold ,"EVI"))
## [1] "MOD13A2_EVI_2016_161.tif" "MOD13A2_EVI_2016_177.tif"


Looping over different Options files

If you need to process different MODIS products, you can prepare beforehand different MODIStsp options files by using the GUI, and then loop over them like this:

opts_files <- c(system.file("testdata/test_MOD13A2.json", package = "MODIStsp"), 
                system.file("testdata/test_MOD10A2.json", package = "MODIStsp"))

for (opts_file in opts_files) {
  MODIStsp(gui = FALSE, options_file = opts_file)
}

# MOD13A2 ouputs
out_fold <- file.path(tempdir(), "MODIStsp/VI_16Days_1Km_v6") 
list.files(out_fold)
## [1] "EVI"         "NDVI"        "QA_usef"     "Time_Series"
list.files(file.path(out_fold ,"EVI"))
## [1] "MOD13A2_EVI_2016_161.tif" "MOD13A2_EVI_2016_177.tif"
# MOD10A2 ouputs
out_fold <- file.path(tempdir(), "MODIStsp/Surf_Temp_8Days_1Km_v6") 
list.files(out_fold)
## [1] "Days_Clear"    "LST_Day_1km"   "LST_Night_1km" "Time_Series"
list.files(file.path(out_fold ,"LST_Night_1km"))
## [1] "MOD11A2_LST_Night_1km_2016_153.tif"
## [2] "MOD11A2_LST_Night_1km_2016_161.tif"
## [3] "MOD11A2_LST_Night_1km_2016_169.tif"
## [4] "MOD11A2_LST_Night_1km_2016_177.tif"


Looping over different spatial extents

Specifying also the spatial_file_path_ parameter overrides for example the output extent of the selected Options File. This allows to perform the same preprocessing on different extents using a single Options File. For example:

## [1] "/home/lb/R/x86_64-pc-linux-gnu-library/3.5/MODIStsp/testdata/lakeshapes//garda_lake.shp"
## [2] "/home/lb/R/x86_64-pc-linux-gnu-library/3.5/MODIStsp/testdata/lakeshapes//iseo_lake.shp"

outfiles_iseo <- list.files(
  file.path(tempdir(), "MODIStsp/iseo_lake/VI_16Days_1Km_v6/EVI"),
  full.names = TRUE)
plot(raster(outfiles_iseo[1]))