sen2r (version 1.2.1)

s2_download: Download S2 products.

Description

The function downloads S2 products. Input filenames must be elements obtained with s2_list function (each element must be a URL, and the name the product name).

Usage

s2_download(s2_prodlist = NULL, downloader = "builtin", apihub = NA,
  tile = NULL, outdir = ".", order_lta = TRUE, overwrite = FALSE)

Arguments

s2_prodlist

Named character: list of the products to be downloaded, in the format safelist (see '>safelist). Alternatively, it can be the path of a JSON file exported by s2_order.

downloader

Executable to use to download products (default: "builtin"). Alternatives are "builtin" or "aria2" (this requires aria2c to be installed).

apihub

Path of the "apihub.txt" file containing credentials of SciHub account. If NA (default), the default location inside the package will be used.

tile

Deprecated argument

outdir

(optional) Full name of the existing output directory where the files should be created (default: current directory).

order_lta

Logical: if TRUE (default), products which are not available for direct download are ordered from the Long Term Archive; if FALSE, they are simply skipped.

overwrite

Logical value: should existing output archives be overwritten? (default: FALSE)

Value

NULL (the function is called for its side effects)

Examples

Run this code
# NOT RUN {
single_s2 <- paste0("https://scihub.copernicus.eu/apihub/odata/v1/",
  "Products(\'c7142722-42bf-4f93-b8c5-59fd1792c430\')/$value")
names(single_s2) <- "S2A_MSIL1C_20170613T101031_N0205_R022_T32TQQ_20170613T101608.SAFE"
# (this is equivalent to:
# single_s2 <- example_s2_list[1]
# where example_s2_list is the output of the example of the
# s2_list() function)

# Download the whole product
s2_download(single_s2, outdir=tempdir())

#' # Download the whole product - using aria2
s2_download(single_s2, outdir=tempdir(), downloader = "aria2")

# Download more products, ordering the ones stored in the Long Term Archive
pos <- sf::st_sfc(sf::st_point(c(-57.8815,-51.6954)), crs = 4326)
time_window <- as.Date(c("2018-02-21", "2018-03-20"))
list_safe <- s2_list(spatial_extent = pos, time_interval = time_window)
s2_download(list_safe, outdir=tempdir())
# }

Run the code above in your browser using DataCamp Workspace