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
library(MODIStsp)
# --> Specify the path to a valid options file saved in advance from MODIStsp GUI
options_file <- "X:/yourpath/youroptions.json"
# --> Launch the processing
MODIStsp(gui = FALSE, options_file = options_file)
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, by looping on an array of spatial files representing the desired output extents. For example:
library(MODIStsp)
# --> Specify the path to a valid options file saved in advance from MODIStsp GUI
options_file <- "X:/yourpath/youroptions.json"
# --> Create a character array containing a list of shapefiles (or other spatial files)
extent_list <- list.files("X:/path/containing/some/shapefiles/", "\\.shp$")
# --> Loop on the list of spatial files and run MODIStsp using each of them to automatically
# define the output extent (A separate output folder is created for each input spatial file).
for (single_shape in extent_list) {
MODIStsp(gui = FALSE, options_file = options_file,
spatial_file_path = single_shape )
}