# 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 Landsat-8 images
lsDownload(satellite = "ls8",
username = "username",
password = "password",
startDate = as.Date("01-01-2018","%d-%m-%Y"),
endDate = as.Date("18-01-2018","%d-%m-%Y"),
pathrow = list(c(200, 31), c(200, 30)),
untar = TRUE,
AppRoot = src)
# folder with the Landsat-8 untared images
src.ls8 <-file.path(src,"Landsat8")
tif.src <- file.path(src.ls8, "untar")
# mosaic the Landsat-8 images
lsMosaic(src = tif.src,
AppRoot = src.ls8,
out.name = "Navarre",
extent = ex.navarre,
gutils = TRUE)
# path to the folder with mosaicked images
src2 <- file.path(src.ls8, "Navarre")
# generate NDVI images of Navarre
src3 <- file.path(src.ls8, "Navarre_Variables")
dir.create(src3)
ls8FolderToVar(src2,
fun = varNDVI,
AppRoot = src3,
overwrite = TRUE)
flist <- list.files(file.path(src3,"NDVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
file.raster <- raster(flist[1])
spplot(file.raster)
# }
Run the code above in your browser using DataLab