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