# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
src <- paste0(tempdir(),"/Path_for_downloading_folder")
print(src)
src.mod <- file.path(src, "Modis","MOD11A1")
src.mod.hdf <- file.path(src.mod, "hdf")
img.list <- modSearch(product = "MOD11A1",
startDate = as.Date("01-01-2011", "%d-%m-%Y"),
endDate = as.Date("01-01-2011", "%d-%m-%Y"),
collection = 6,
extent = ex.navarre,
AppRoot = src.mod.hdf)
# download the images of the list
src.mod <- file.path(src, "Modis", "MOD11A1")
modDownSearch(searchres = img.list,
username = "username",
password = "password",
AppRoot = src.mod.hdf)
src.tif<-file.path(src.mod,"tif")
# extract the first image
hdf.files <- list.files(src.mod.hdf,
full.names = TRUE,
pattern = "\\.hdf$")
first.hdf.file <- hdf.files[1]
modExtractHDF(filesHDF = first.hdf.file,
AppRoot = src.tif)
# }
Run the code above in your browser using DataLab