# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
src <- paste0(tempdir(),"/Path_for_downloading_folder")
print(src)
# download MOD09 images
modDownload(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 = src, # output folder for tif images
extract.tif = TRUE,
collection = 6,
extent = ex.navarre)
# assign src.mod as the output folder from modMosaic
src.mod <- file.path(src, "Modis", "MOD09GA") # output directory
src.tif <- file.path(src.mod, "tif") # input directory
# mosaic the MODIS images
modMosaic(src.tif,
AppRoot = src.mod,
out.name = "Navarre")
# path to the folder with the mosaicked images
src.navarre <- file.path(src.mod, "Navarre")
# generate NDVI images of Navarre
src.variables <- file.path(src.mod, "Variables")
dir.create(src.variables)
modFolderToVar(src = src.navarre,
fun = varEVI,
scfun = getRGISToolsOpt("MOD09SCL"),
AppRoot = src.variables,
overwrite = TRUE)
# import mosaicked images (.tif) to the environment in `R'
flist <- list.files(file.path(src.variables,"EVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
files.raster <- lapply(flist,raster)
spplot(files.raster[[1]],at=seq(-1,2.5))
# }
Run the code above in your browser using DataLab