The function orders S2 products from Long Term Archive.

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



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.


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


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


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


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.


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.


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


License: GPL 3.0


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. DOI: 10.1016/j.cageo.2020.104473, URL:


# \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 #> "'c88086ac-8087-4adb-866e-baeffec5eb68')/$value" #> S2B_MSIL1C_20180227T134629_N0206_R081_T21FVC_20180227T200327.SAFE #> "'fa8cba66-7b8b-45aa-9038-9521d7658bad')/$value" #> S2A_MSIL1C_20180301T133641_N0206_R038_T21FVC_20180301T145524.SAFE #> "'d9a50ba4-8213-421e-92da-e5a487766dc2')/$value" #> S2B_MSIL1C_20180306T133629_N0206_R038_T21FVC_20180306T183210.SAFE #> "'5ae358f2-8589-493b-bb6d-09df04ec0ff9')/$value" #> S2A_MSIL1C_20180311T133641_N0206_R038_T21FVC_20180311T163528.SAFE #> "'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, footprint, uuid, 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)
#> [2020-08-15 15:21:42] Check if products are already available for #> download...
#> [2020-08-15 15:21:43] 6 Sentinel-2 images are already online.
#> [2020-08-15 15:21:43] Ordering 1 Sentinel-2 images stored in the Long #> Term Archive...
#> [2020-08-15 15:21:43] 1 of 1 Sentinel-2 images were correctly ordered. #> You can check at a later time if the ordered products are #> available online using the command: #>   safe_is_online("/home/lranghetti/.sen2r/lta_orders/lta_20200815_152143.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_20200815_152143.json"
#> 6 out of 7 products are online.
#> S2B_MSIL1C_20180227T134629_N0206_R081_T21FVC_20180227T200327.SAFE #> TRUE #> S2A_MSIL1C_20180301T133641_N0206_R038_T21FVC_20180301T145524.SAFE #> TRUE #> S2B_MSIL1C_20180306T133629_N0206_R038_T21FVC_20180306T183210.SAFE #> TRUE #> S2A_MSIL1C_20180311T133641_N0206_R038_T21FVC_20180311T163528.SAFE #> TRUE #> S2A_MSIL1C_20180314T134631_N0206_R081_T21FVC_20180314T150724.SAFE #> TRUE #> S2B_MSIL1C_20180316T133639_N0206_R038_T21FVC_20180316T145348.SAFE #> TRUE #> S2B_MSIL1C_20180224T133629_N0206_R038_T21FVC_20180224T194845.SAFE #> FALSE
# }