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