# 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))
# }
Run the code above in your browser using DataLab