The function orders S2 products from Long Term Archive (https://scihub.copernicus.eu/userguide/LongTermArchive).

s2_order(s2_prodlist = NULL, export_prodlist = TRUE, delay = 5,
  apihub = NA)

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 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.

Value

A named vector, containing the selection 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 ordered products was saved.

Note

License: GPL 3.0

Examples

# \donttest{ # 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)
#> A named vector with 7 SAFE archives. #> S2B_MSIL1C_20180224T133629_N0206_R038_T21FVC_20180224T194845.SAFE #> "https://scihub.copernicus.eu/apihub/odata/v1/Products('c88086ac-8087-4adb-866e-baeffec5eb68')/$value" #> S2B_MSIL1C_20180227T134629_N0206_R081_T21FVC_20180227T200327.SAFE #> "https://scihub.copernicus.eu/apihub/odata/v1/Products('fa8cba66-7b8b-45aa-9038-9521d7658bad')/$value" #> S2A_MSIL1C_20180301T133641_N0206_R038_T21FVC_20180301T145524.SAFE #> "https://scihub.copernicus.eu/apihub/odata/v1/Products('d9a50ba4-8213-421e-92da-e5a487766dc2')/$value" #> S2B_MSIL1C_20180306T133629_N0206_R038_T21FVC_20180306T183210.SAFE #> "https://scihub.copernicus.eu/apihub/odata/v1/Products('5ae358f2-8589-493b-bb6d-09df04ec0ff9')/$value" #> S2A_MSIL1C_20180311T133641_N0206_R038_T21FVC_20180311T163528.SAFE #> "https://scihub.copernicus.eu/apihub/odata/v1/Products('266e369c-9ab5-486e-83b3-7180b6956616')/$value" #> ...with 2 more elements. #> The following attributes are included: mission, level, id_tile, id_orbit, sensing_datetime, ingestion_datetime, clouds, online.
# (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)
#> [2019-11-12 14:21:02] Check if products are already available for download...
#> [2019-11-12 14:21:03] 6 Sentinel-2 images are already available and will not be ordered.
#> [2019-11-12 14:21:03] Ordering 1 Sentinel-2 images stored in the Long Term Archive...
#> [2019-11-12 14:21:04] 1 of 1 Sentinel-2 images were correctly ordered. You can check at a later time if the ordered products were made available using the command: #> #> safe_is_online("/home/lranghetti/.sen2r/lta_orders/lta_20191112_142104.json")
# Check in a second time if the product was made available (order_path <- attr(ordered_prods, "path"))
#> [1] "/home/lranghetti/.sen2r/lta_orders/lta_20191112_142104.json"
safe_is_online(order_path)
#> S2B_MSIL1C_20180227T134629_N0206_R081_T21FVC_20180227T200327.SAFE #> FALSE
# }