s2_download: Download S2 products.

View source: R/s2_download.R

s2_downloadR Documentation

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,
  service = NA,
  tile = NULL,
  outdir = ".",
  order_lta = TRUE,
  abort = 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.

service

Character: it can be "dhus" or "apihub", in which cases the required service is forced instead that the one present in the URLs passed through argument s2_prodlist. If NA (default), the service present in the URLs is maintained.

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.

abort

Logical parameter: if TRUE (default), the function aborts in case of errors during downloads; if FALSE, a warning is shown and download of subsequent products continues.

overwrite

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

Value

Vector character with the list ot the output products (being downloaded or already existing).

Note

License: GPL 3.0

Author(s)

Luigi Ranghetti, phD (2020)

Lorenzo Busetto, phD (2019)

References

L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473")}, URL: https://sen2r.ranghetti.info/.

Examples

## Not run: 
single_s2 <- paste0("gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/",
  "S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE/")
names(single_s2) <- "S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.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())
file.info(file.path(tempdir(),names(single_s2)))

## End(Not run)

sen2r documentation built on Nov. 10, 2023, 9:08 a.m.