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