The function retrieves the list of available Sentinel-2 products satisfying given search criteria.

s2_list(
  spatial_extent = NULL,
  tile = NULL,
  orbit = NULL,
  time_interval = c(Sys.Date() - 10, Sys.Date()),
  time_period = "full",
  level = "auto",
  server = "scihub",
  apihub = NA,
  service = "apihub",
  max_cloud = 100,
  availability = "ignore",
  output_type = "deprecated"
)

Arguments

spatial_extent

A valid spatial object object of class sf, sfc or sfg

tile

string array Sentinel-2 Tiles to be considered string (5-length character)

orbit

string array Sentinel-2 orbit numbers to be considered

time_interval

Dates to be considered, as a temporal vector (class POSIXct or Date, or string in YYYY-mm-dd format) of length 1 (specific day) or 2 (time interval).

time_period

(optional) Character:

  • "full" (default) means that all the images included in the time window are considered;

  • "seasonal" means that only the single seasonal periods in the window are used (i.e., with a time window from 2015-06-01 to 2017-08-31, the periods 2015-06-01 to 2015-08-31, 2016-06-01 to 2016-08-31 and 2017-06-01 to 2017-08-31 are considered).

level

Character vector with one of the following: - "auto" (default): check if level-2A is available on SciHub: if so, list it; if not, list the corresponding level-1C product - "L1C": list available level-1C products - "L2A": list available level-2A products

server

The servers where archives are searched. Currently, only "scihub" is supported (Google Cloud will be implemented in future). In case of multiple values, they are used in order of priority. If availability = "check", products on LTA are always left as last choice.

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" (default), in which cases the required service is forced instead that the one present in the URLs passed through argument s2_prodlist.

max_cloud

Integer number (0-100) containing the maximum cloud level of the tiles to be listed (default: no filter).

availability

Character argument, determining which products have to be returned:

  • "online" : only archive names already available for download are returned;

  • "lta": only archive names stored in the Long Term Archive are returned;

  • "check": all archive names are returned, checking if they are available or not for download (see "Value" to know how to distinguish each other);

  • "ignore" (default): all archive names are returned, without doing the check (running the function is faster).

output_type

Deprecated (use as.data.table to obtain a data.table).

Value

An object of class safelist. The attribute online contains logical values: in case availability != "ignore", values are TRUE / FALSE for products available for download / stored in the Long Term Archive; otherwise, values are set to NA.

Note

License: GPL 3.0

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. doi: 10.1016/j.cageo.2020.104473 , URL: https://sen2r.ranghetti.info/.

Author

Lorenzo Busetto, phD (2019) - Inspired by function getSentinel_query of package getSpatialData by J. Schwalb-Willmann

Luigi Ranghetti, phD (2019) luigi@ranghetti.info

Examples

# \donttest{ pos <- sf::st_sfc(sf::st_point(c(9.85,45.81)), crs = 4326) time_window <- as.Date(c("2016-05-01", "2017-07-30")) # Full-period list if (is_scihub_configured()) { example_s2_list <- s2_list( spatial_extent = pos, tile = "32TNR", time_interval = time_window, orbit = "065" ) } else { example_s2_list <- as(character(), "safelist") } print(example_s2_list)
#> A named vector with 47 SAFE archives. #> S2A_MSIL1C_20160502T102032_N0201_R065_T32TNR_20160502T102027.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('fde01d3f-8a0d-46cb-b65d-3e32eff93f1d')/$value" #> S2A_MSIL1C_20160512T102032_N0202_R065_T32TNR_20160512T102029.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('4b785773-ba94-49b2-ae81-9b4b08749f70')/$value" #> S2A_MSIL1C_20160522T102032_N0202_R065_T32TNR_20160522T102029.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('4abf7965-0b26-431b-8708-74de427c0112')/$value" #> S2A_MSIL1C_20160611T102032_N0202_R065_T32TNR_20160611T102026.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('68afcf6b-4ec6-48da-9b65-6cd41ff47a49')/$value" #> S2A_MSIL1C_20160621T102022_N0204_R065_T32TNR_20160621T102024.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('9bb6d780-c226-4f59-bad0-1daedfdce9d5')/$value" #> ...with 42 more elements. #> The following attributes are included: mission, level, id_tile, id_orbit, sensing_datetime, ingestion_datetime, clouds, footprint, uuid, online.
# Print the dates of the retrieved products safe_getMetadata(example_s2_list, "sensing_datetime")
#> S2A_MSIL1C_20160502T102032_N0201_R065_T32TNR_20160502T102027.SAFE #> "2016-05-02 10:20:32 UTC" #> S2A_MSIL1C_20160512T102032_N0202_R065_T32TNR_20160512T102029.SAFE #> "2016-05-12 10:20:32 UTC" #> S2A_MSIL1C_20160522T102032_N0202_R065_T32TNR_20160522T102029.SAFE #> "2016-05-22 10:20:32 UTC" #> S2A_MSIL1C_20160611T102032_N0202_R065_T32TNR_20160611T102026.SAFE #> "2016-06-11 10:20:32 UTC" #> S2A_MSIL1C_20160621T102022_N0204_R065_T32TNR_20160621T102024.SAFE #> "2016-06-21 10:20:22 UTC" #> S2A_MSIL1C_20160701T102022_N0204_R065_T32TNR_20160701T102057.SAFE #> "2016-07-01 10:20:22 UTC" #> S2A_MSIL1C_20160711T102032_N0204_R065_T32TNR_20160711T102030.SAFE #> "2016-07-11 10:20:32 UTC" #> S2A_MSIL1C_20160721T102032_N0204_R065_T32TNR_20160721T102059.SAFE #> "2016-07-21 10:20:32 UTC" #> S2A_MSIL1C_20160731T102032_N0204_R065_T32TNR_20160731T102107.SAFE #> "2016-07-31 10:20:32 UTC" #> S2A_MSIL1C_20160810T102032_N0204_R065_T32TNR_20160810T102044.SAFE #> "2016-08-10 10:20:32 UTC" #> S2A_MSIL1C_20160820T102022_N0204_R065_T32TNR_20160820T102112.SAFE #> "2016-08-20 10:20:22 UTC" #> S2A_MSIL1C_20160830T102022_N0204_R065_T32TNR_20160830T102052.SAFE #> "2016-08-30 10:20:22 UTC" #> S2A_MSIL1C_20160909T102022_N0204_R065_T32TNR_20160909T102108.SAFE #> "2016-09-09 10:20:22 UTC" #> S2A_MSIL1C_20160919T102022_N0204_R065_T32TNR_20160919T102112.SAFE #> "2016-09-19 10:20:22 UTC" #> S2A_MSIL1C_20160929T102022_N0204_R065_T32TNR_20160929T102344.SAFE #> "2016-09-29 10:20:22 UTC" #> S2A_MSIL1C_20161009T102022_N0204_R065_T32TNR_20161009T102522.SAFE #> "2016-10-09 10:20:22 UTC" #> S2A_MSIL1C_20161019T102032_N0204_R065_T32TNR_20161019T102353.SAFE #> "2016-10-19 10:20:32 UTC" #> S2A_MSIL1C_20161029T102132_N0204_R065_T32TNR_20161029T102445.SAFE #> "2016-10-29 10:21:32 UTC" #> S2A_MSIL1C_20161108T102232_N0204_R065_T32TNR_20161108T102425.SAFE #> "2016-11-08 10:22:32 UTC" #> S2A_MSIL1C_20161118T102322_N0204_R065_T32TNR_20161118T102318.SAFE #> "2016-11-18 10:23:22 UTC" #> S2A_MSIL1C_20161128T102352_N0204_R065_T32TNR_20161128T102354.SAFE #> "2016-11-28 10:23:52 UTC" #> S2A_MSIL1C_20161208T102422_N0204_R065_T32TNR_20161208T102418.SAFE #> "2016-12-08 10:24:22 UTC" #> S2A_MSIL1C_20161218T102432_N0204_R065_T32TNR_20161218T102606.SAFE #> "2016-12-18 10:24:32 UTC" #> S2A_MSIL1C_20161228T102432_N0204_R065_T32TNR_20161228T102428.SAFE #> "2016-12-28 10:24:32 UTC" #> S2A_MSIL1C_20170107T102401_N0204_R065_T32TNR_20170107T102658.SAFE #> "2017-01-07 10:24:01 UTC" #> S2A_MSIL1C_20170127T102301_N0204_R065_T32TNR_20170127T102258.SAFE #> "2017-01-27 10:23:01 UTC" #> S2A_MSIL1C_20170206T102211_N0204_R065_T32TNR_20170206T102733.SAFE #> "2017-02-06 10:22:11 UTC" #> S2A_MSIL1C_20170216T102101_N0204_R065_T32TNR_20170216T102204.SAFE #> "2017-02-16 10:21:01 UTC" #> S2A_MSIL1C_20170226T102021_N0204_R065_T32TNR_20170226T102458.SAFE #> "2017-02-26 10:20:21 UTC" #> S2A_MSIL1C_20170308T102021_N0204_R065_T32TNR_20170308T102514.SAFE #> "2017-03-08 10:20:21 UTC" #> S2A_MSIL1C_20170318T102011_N0204_R065_T32TNR_20170318T102014.SAFE #> "2017-03-18 10:20:11 UTC" #> S2A_MSIL1C_20170328T102021_N0204_R065_T32TNR_20170328T102018.SAFE #> "2017-03-28 10:20:21 UTC" #> S2A_MSIL1C_20170407T102021_N0204_R065_T32TNR_20170407T102343.SAFE #> "2017-04-07 10:20:21 UTC" #> S2A_MSIL1C_20170417T102021_N0204_R065_T32TNR_20170417T102334.SAFE #> "2017-04-17 10:20:21 UTC" #> S2A_MSIL2A_20170427T102031_N0205_R065_T32TNR_20170427T102025.SAFE #> "2017-04-27 10:20:31 UTC" #> S2A_MSIL2A_20170507T102031_N0205_R065_T32TNR_20170507T102319.SAFE #> "2017-05-07 10:20:31 UTC" #> S2A_MSIL2A_20170517T102031_N0205_R065_T32TNR_20170517T102352.SAFE #> "2017-05-17 10:20:31 UTC" #> S2A_MSIL2A_20170527T102031_N0205_R065_T32TNR_20170527T102301.SAFE #> "2017-05-27 10:20:31 UTC" #> S2A_MSIL2A_20170606T102031_N0205_R065_T32TNR_20170606T102456.SAFE #> "2017-06-06 10:20:31 UTC" #> S2A_MSIL2A_20170616T102021_N0205_R065_T32TNR_20170616T102331.SAFE #> "2017-06-16 10:20:21 UTC" #> S2A_MSIL2A_20170626T102021_N0205_R065_T32TNR_20170626T102321.SAFE #> "2017-06-26 10:20:21 UTC" #> S2B_MSIL1C_20170701T102029_N0205_R065_T32TNR_20170701T102338.SAFE #> "2017-07-01 10:20:29 UTC" #> S2A_MSIL2A_20170706T102021_N0205_R065_T32TNR_20170706T102301.SAFE #> "2017-07-06 10:20:21 UTC" #> S2B_MSIL1C_20170711T102029_N0205_R065_T32TNR_20170711T102309.SAFE #> "2017-07-11 10:20:29 UTC" #> S2A_MSIL1C_20170716T102021_N0205_R065_T32TNR_20170716T102324.SAFE #> "2017-07-16 10:20:21 UTC" #> S2B_MSIL1C_20170721T102029_N0205_R065_T32TNR_20170721T102331.SAFE #> "2017-07-21 10:20:29 UTC" #> S2A_MSIL2A_20170726T102021_N0205_R065_T32TNR_20170726T102259.SAFE #> "2017-07-26 10:20:21 UTC"
# Seasonal-period list if (is_scihub_configured()) { example_s2_list <- s2_list( spatial_extent = pos, tile = "32TNR", time_interval = time_window, time_period = "seasonal" ) } else { example_s2_list <- as(character(), "safelist") } print(example_s2_list)
#> A named vector with 28 SAFE archives. #> S2A_MSIL1C_20160502T102032_N0201_R065_T32TNR_20160502T102027.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('fde01d3f-8a0d-46cb-b65d-3e32eff93f1d')/$value" #> S2A_MSIL1C_20160509T101032_N0202_R022_T32TNR_20160509T101645.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('abf24c65-2ff6-4c9a-9309-425425475d36')/$value" #> S2A_MSIL1C_20160512T102032_N0202_R065_T32TNR_20160512T102029.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('4b785773-ba94-49b2-ae81-9b4b08749f70')/$value" #> S2A_MSIL1C_20160519T101032_N0202_R022_T32TNR_20160519T101312.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('e1f000b8-e9c3-421b-88c2-08a9046d1a82')/$value" #> S2A_MSIL1C_20160522T102032_N0202_R065_T32TNR_20160522T102029.SAFE #> "https://apihub.copernicus.eu/apihub/odata/v1/Products('4abf7965-0b26-431b-8708-74de427c0112')/$value" #> ...with 23 more elements. #> The following attributes are included: mission, level, id_tile, id_orbit, sensing_datetime, ingestion_datetime, clouds, footprint, uuid, online.
# Print the dates of the retrieved products safe_getMetadata(example_s2_list, "sensing_datetime")
#> S2A_MSIL1C_20160502T102032_N0201_R065_T32TNR_20160502T102027.SAFE #> "2016-05-02 10:20:32 UTC" #> S2A_MSIL1C_20160509T101032_N0202_R022_T32TNR_20160509T101645.SAFE #> "2016-05-09 10:10:32 UTC" #> S2A_MSIL1C_20160512T102032_N0202_R065_T32TNR_20160512T102029.SAFE #> "2016-05-12 10:20:32 UTC" #> S2A_MSIL1C_20160519T101032_N0202_R022_T32TNR_20160519T101312.SAFE #> "2016-05-19 10:10:32 UTC" #> S2A_MSIL1C_20160522T102032_N0202_R065_T32TNR_20160522T102029.SAFE #> "2016-05-22 10:20:32 UTC" #> S2A_MSIL1C_20160529T101032_N0202_R022_T32TNR_20160529T101030.SAFE #> "2016-05-29 10:10:32 UTC" #> S2A_MSIL1C_20160608T101032_N0202_R022_T32TNR_20160608T101220.SAFE #> "2016-06-08 10:10:32 UTC" #> S2A_MSIL1C_20160611T102032_N0202_R065_T32TNR_20160611T102026.SAFE #> "2016-06-11 10:20:32 UTC" #> S2A_MSIL1C_20160618T101032_N0204_R022_T32TNR_20160618T101515.SAFE #> "2016-06-18 10:10:32 UTC" #> S2A_MSIL1C_20160621T102022_N0204_R065_T32TNR_20160621T102024.SAFE #> "2016-06-21 10:20:22 UTC" #> S2A_MSIL1C_20160628T101032_N0204_R022_T32TNR_20160628T101026.SAFE #> "2016-06-28 10:10:32 UTC" #> S2A_MSIL1C_20160701T102022_N0204_R065_T32TNR_20160701T102057.SAFE #> "2016-07-01 10:20:22 UTC" #> S2A_MSIL1C_20160708T101032_N0204_R022_T32TNR_20160708T101602.SAFE #> "2016-07-08 10:10:32 UTC" #> S2A_MSIL1C_20160711T102032_N0204_R065_T32TNR_20160711T102030.SAFE #> "2016-07-11 10:20:32 UTC" #> S2A_MSIL1C_20160718T101032_N0204_R022_T32TNR_20160718T101028.SAFE #> "2016-07-18 10:10:32 UTC" #> S2A_MSIL1C_20160721T102032_N0204_R065_T32TNR_20160721T102059.SAFE #> "2016-07-21 10:20:32 UTC" #> S2A_MSIL2A_20170507T102031_N0205_R065_T32TNR_20170507T102319.SAFE #> "2017-05-07 10:20:31 UTC" #> S2A_MSIL2A_20170517T102031_N0205_R065_T32TNR_20170517T102352.SAFE #> "2017-05-17 10:20:31 UTC" #> S2A_MSIL2A_20170527T102031_N0205_R065_T32TNR_20170527T102301.SAFE #> "2017-05-27 10:20:31 UTC" #> S2A_MSIL2A_20170606T102031_N0205_R065_T32TNR_20170606T102456.SAFE #> "2017-06-06 10:20:31 UTC" #> S2A_MSIL2A_20170616T102021_N0205_R065_T32TNR_20170616T102331.SAFE #> "2017-06-16 10:20:21 UTC" #> S2A_MSIL2A_20170626T102021_N0205_R065_T32TNR_20170626T102321.SAFE #> "2017-06-26 10:20:21 UTC" #> S2B_MSIL1C_20170701T102029_N0205_R065_T32TNR_20170701T102338.SAFE #> "2017-07-01 10:20:29 UTC" #> S2A_MSIL2A_20170706T102021_N0205_R065_T32TNR_20170706T102301.SAFE #> "2017-07-06 10:20:21 UTC" #> S2B_MSIL1C_20170711T102029_N0205_R065_T32TNR_20170711T102309.SAFE #> "2017-07-11 10:20:29 UTC" #> S2A_MSIL1C_20170716T102021_N0205_R065_T32TNR_20170716T102324.SAFE #> "2017-07-16 10:20:21 UTC" #> S2B_MSIL1C_20170721T102029_N0205_R065_T32TNR_20170721T102331.SAFE #> "2017-07-21 10:20:29 UTC" #> S2A_MSIL2A_20170726T102021_N0205_R065_T32TNR_20170726T102259.SAFE #> "2017-07-26 10:20:21 UTC"
# }