# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
# set the download folder
s.start <- Sys.time()
src <- paste0(tempdir(),"/Path_for_downloading_folder")
print(src)
# download the images
modDownload(product = "MOD09GA",
startDate = as.Date("30-07-2018", "%d-%m-%Y"),
endDate = as.Date("06-08-2018", "%d-%m-%Y"),
username = "username",
password = "password",
AppRoot = src,
extract.tif = TRUE,
collection = 6,
extent = ex.navarre)
# set folder path where MOD09GA images will be saved
src1 <- file.path(src,"Modis","MOD09GA")
# set the tif folder path
tif.src <- file.path(src1,"tif")
# mosaic and cut navarre region
modMosaic(tif.src,
AppRoot = src1,
out.name = "Navarre",
extent = ex.navarre)
# change src to navarre folder
src2 <- file.path(src1,"Navarre")
# calculate NDVI from navarre folder
modFolderToVar(src2,
fun = varNDVI,
AppRoot = dirname(src2),
overwrite = TRUE)
# change src TS_sample
src3 <- file.path(dirname(src2),"NDVI")
# create the Rdata
genSaveTSRData(src3, ts.name = "ModisNDVI", AppRoot = src1)
# remove values out of 0-1 range
ModisNDVI.lim <- genLimitRasterRange(ModisNDVI, mn = 0, mx = 1)
# plot the ndvi images
spplot(ModisNDVI.lim)
s.end <- Sys.time()
s.end - s.start
# }
Run the code above in your browser using DataLab