# 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 Sentinel-2 images
senDownload(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 = src)
# folder with the unzipped images
src.sen <- file.path(src, "Sentinel-2")
src.unzip <- file.path(src.sen, "unzip")
# mosaic the Sentinel-2 images
senMosaic(src.unzip,
AppRoot = src.sen,
gutils = TRUE,
out.name = "Navarre")
# load and plot a Sentinel-2 image
files <- list.files(src.sen, pattern = "\\.tif$", full.names = TRUE ,recursive = TRUE)
# print Sentinel-2 bands
getRGISToolsOpt("SEN2BANDS")
file.rgb <- stack(files[grepl("TCI",files)][1])
plotRGB(file.rgb)
# }
Run the code above in your browser using DataLab