# 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 Landsat-7 images
lsDownSearch(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 = wdir)
# folder with the Landsat-7 untared images
wdir.ls7 <-file.path(wdir,"Landsat7")
wdir.ls7.untar <- file.path(wdir.ls7, "untar")
# mosaic the Landsat-7 images
lsMosaic(wdir.ls7.untar,
AppRoot = wdir.ls7,
out.name = "Navarre",
extent = ex.navarre,
gutils = TRUE)
# folder with the mosaicked images
wdir.ls7.navarre <- file.path(wdir.ls7, "Navarre")
# generate NDVI images of Navarre
wdir.ls7.var <- file.path(wdir.ls7, "Navarre_Variables")
dir.create(wdir.ls7.var)
ls7FolderToVar(wdir.ls7.navarre,
fun = varNDVI,
AppRoot = wdir.ls7.var,
overwrite = TRUE)
files.ls7.ndvi <- list.files(file.path(wdir.ls7.var,"NDVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
img.ls7.ndvi <- raster(files.ls7.ndvi[1])
spplot(img.ls7.ndvi)
# }
Run the code above in your browser using DataLab