Learn R Programming

RGISTools (version 0.9.7)

senDownSearch: Download Sentinel images from a search list

Description

senDownSearch downloads the images from a list of uniform resource locators (URLs) generated by the senSearch function from ESA<U+2019>s `SciHub' web service. The images are saved as GTiff files in the AppRoot directory.

Usage

senDownSearch(searchres, AppRoot, username = NULL, password = NULL,
  nattempts = 5, unzip = FALSE, overwrite = FALSE, ...)

Arguments

searchres

the output from the senSearch function.

AppRoot

the directory where the outcoming time series are saved.

username

ESA<U+2019>s `SciHub' username.

password

ESA<U+2019>s `SciHub' password.

nattempts

the number of attempts to download an image in case it becomes corrupted.

unzip

logical argument. If TRUE, unzips the images.

overwrite

logical argument. If TRUE, overwrites the existing images with the same name.

...

arguments for nested functions.

Details

senDownSearch downloads the list of URLs provided by senSearch. In case the process is interrupted, the image file could be corrupted. The function detects the corrupted files and restarts the process. To prevent the computer from crashing, there is a maximum number of attempts to try to donwnload the image (nattempts). The default number of attempts is set to 3. The function requires an ESA<U+2019>s `SciHub' account, which can be obtained here.

Examples

Run this code
# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
# download S2MSI1C products sensed by Sentinel-2
# in July-August 2018
searchres <- senSearch(startDate = as.Date("2018-07-29","%Y-%m-%d"),
                       endDate = as.Date("2018-08-06","%Y-%m-%d"),
                       platform = "Sentinel-2",
                       extent = ex.navarre,
                       product = "S2MSI1C",
                       username = "username",
                       password = "password")

# filtering the path R094 where Navarre is located
names(searchres)
searchres.R094 <- searchres[grepl("R094", names(searchres))]
names(searchres.R094)
# list the dates in searchres
senGetDates(names(searchres.R094),format="%Y%j")
src <- paste0(tempdir(),"/Path_for_downloading_folder")
# donwload the imagery
senDownSearch(searchres = searchres.R094,
              username = "username",
              password = "password",
              AppRoot = src,
              unzip = TRUE)
src.unzip <- file.path(src,"unzip")
files<-list.files(src.unzip,
                  pattern = "\\TCI.jp2$",
                  full.names = TRUE,
                  recursive = TRUE)
rgb<-stack(files[1])
plotRGB(rgb)
# }

Run the code above in your browser using DataLab