Learn R Programming

sen2r (version 1.3.4)

s2_order: Order S2 products.

Description

The function orders S2 products from Long Term Archive.

Usage

s2_order(
  s2_prodlist = NULL,
  export_prodlist = TRUE,
  delay = 0.5,
  apihub = NA,
  service = NA,
  reorder = TRUE
)

Arguments

s2_prodlist

Named character: list of the products to be ordered, in the format safelist (see '>safelist). Alternatively, it can be the path of a JSON file exported by a previous execution of s2_order, in case the user wants, for any reason, to resubmit the order.

export_prodlist

Logical or character: if TRUE (default), the list of ordered products is saved in a JSON text file, so to be easily retrievable at a later stage with safe_is_online or s2_download; if FALSE, no output files are generated. It is also possible to pass the path of an existing folder in which the JSON file will be saved (otherwise, a default path is used).

delay

Numeric: time frame (in seconds) to leave between two consecutive orders. Default is 0.5 seconds: use a higher value if you encountered errors (i.e. not all the products were correctly ordered).

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.

reorder

Logical: If TRUE, and a json file exported by s2_order is passed as argument to the function, try to order again also the "available" and "ordered" S2 datasets. Otherwise, only order the "notordered" ones.

Value

A named vector, containing the subset of s2_prodlist elements which were ordered. Moreover, the vector includes the following attributes:

  • "available" with the elements of s2_prodlist which were already available for download,

  • "notordered" with the elements of s2_prodlist which were not ordered for any reasons,

  • "path" (only if argument export_prodlist is not FALSE) with the path of the json file in which the list of the products (ordered, available and not ordered) was saved (if export_prodlist = TRUE).

Examples

Run this code
# NOT RUN {
# Generate the lists of products
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)
print(list_safe)
# (at the time the documentation was written, this list was containing 5
# archives already available online and 2 stored in the Long Term Archive)

# Order the products
ordered_prods <- s2_order(list_safe)

# Check in a second time if the product was made available
(order_path <- attr(ordered_prods, "path"))
safe_is_online(order_path)
# }

Run the code above in your browser using DataLab