# 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 Sentinel-2 images
senDownSearch(startDate = as.Date("2018210","%Y%j"),
endDate = as.Date("2018218","%Y%j"),
platform = "Sentinel-2",
extent = ex.navarre,
product = "S2MSI1C",
pathrow = c("R094"),
username = "username",
password = "password",
AppRoot = wdir)
# folder with the unzipped images from Sentinel-2
wdir.sen <- file.path(wdir,"Sentinel-2")
wdir.sen.unzip <- file.path(wdir.sen, "unzip")
# mosaic the Sentinel-2 images
senMosaic(wdir.sen.unzip,
AppRoot = wdir.sen,
gutils = TRUE,
out.name = "Navarre")
# path to the folder with the mosaicked images
wdir.sen.navarre <- file.path(wdir.sen, "Navarre")
wdir.sen.var <- file.path(wdir.sen.navarre, "Navarre_Variables")
dir.create(wdir.sen.var)
# generate EVI images of Navarre
senFolderToVar(wdir.sen.navarre,
fun = varEVI,
resbands = c("60m"),
AppRoot = wdir.sen.var)
files.sen.evi <- list.files(file.path(wdir.sen.var,"EVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
img.sen.evi <- lapply(files.sen.evi, raster)
spplot(img.sen.evi[[1]])
# }
Run the code above in your browser using DataLab