The function retrieves the list of available Sentinel-2 products satisfying given search criteria.
A valid spatial object object of class sf
,
sfc
or sfg
string array
Sentinel-2 Tiles to be considered string (5-length character)
string array
Sentinel-2 orbit numbers to be considered
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).
(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).
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
(deprecate) Character vector of length 1, with the names of
the servers on which SAFE archives are searched.
Currently, only "gcloud"
(Google Cloud) is supported.
Old "scihub"
(ESA Sentinel Hub) can no more be used, since November 2023,
when the Copernicus Sentinel Data is no longer available and has been
replaced by the Copernicus Data Space Ecosystem.
See also the section "Details".
deprecated
deprecated
Integer number (0-100) containing the maximum cloud level of the tiles to be listed (default: no filter).
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).
If not provided, "ignore"
is the default value unless
server = c("scihub","gcloud")
(in which case "check"
is used).
(optional) Path where intermediate files (xml) will be created
(it is used only if argument server
includes "gcloud"
).
Default is a temporary directory.
If tmpdir
is a non-empty folder, a random subdirectory will be used.
Deprecated (use as.data.table
to obtain a data.table).
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.
Important: to search and download from Google Cloud, Google Cloud SDK must be installed and configured following the indications in https://cloud.google.com/sdk/docs/install. Notice also that querying Google Cloud can be very slow (while downloading them is generally faster than from SciHub).
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: https://sen2r.ranghetti.info/.
# \donttest{
pos <- sf::st_sfc(sf::st_point(c(9.85,45.81)), crs = 4326)
time_window <- as.Date(c("2020-08-01", "2020-08-11"))
# Full-period list
if (is_gcloud_configured()) {
example_s2_list <- s2_list(
spatial_extent = pos,
tile = "32TNR",
time_interval = time_window,
orbit = "065"
)
} else {
example_s2_list <- as(character(), "safelist")
}
#> Spherical geometry (s2) switched off
#> [2023-11-09 22:26:21] Querying Google Cloud (this can take a very long
#> time)...
#> Spherical geometry (s2) switched on
print(example_s2_list)
#> A named vector with 2 SAFE archives.
#> S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE/"
#> S2A_MSIL2A_20200809T102031_N0214_R065_T32TNR_20200809T130506.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2A_MSIL2A_20200809T102031_N0214_R065_T32TNR_20200809T130506.SAFE/"
#> 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")
#> S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE
#> "2020-08-04 10:15:59 UTC"
#> S2A_MSIL2A_20200809T102031_N0214_R065_T32TNR_20200809T130506.SAFE
#> "2020-08-09 10:20:31 UTC"
# Seasonal-period list
if (is_gcloud_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")
}
#> Spherical geometry (s2) switched off
#> [2023-11-09 22:26:40] Querying Google Cloud (this can take a very long
#> time)...
#> Spherical geometry (s2) switched on
print(example_s2_list)
#> A named vector with 5 SAFE archives.
#> S2B_MSIL2A_20200801T100559_N0214_R022_T32TNR_20200801T135302.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2B_MSIL2A_20200801T100559_N0214_R022_T32TNR_20200801T135302.SAFE/"
#> S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE/"
#> S2A_MSIL2A_20200806T101031_N0214_R022_T32TNR_20200806T115620.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2A_MSIL2A_20200806T101031_N0214_R022_T32TNR_20200806T115620.SAFE/"
#> S2A_MSIL2A_20200809T102031_N0214_R065_T32TNR_20200809T130506.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2A_MSIL2A_20200809T102031_N0214_R065_T32TNR_20200809T130506.SAFE/"
#> S2B_MSIL2A_20200811T100559_N0214_R022_T32TNR_20200811T133733.SAFE
#> "gs://gcp-public-data-sentinel-2/L2/tiles/32/T/NR/S2B_MSIL2A_20200811T100559_N0214_R022_T32TNR_20200811T133733.SAFE/"
#> 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")
#> S2B_MSIL2A_20200801T100559_N0214_R022_T32TNR_20200801T135302.SAFE
#> "2020-08-01 10:05:59 UTC"
#> S2B_MSIL2A_20200804T101559_N0214_R065_T32TNR_20200804T145113.SAFE
#> "2020-08-04 10:15:59 UTC"
#> S2A_MSIL2A_20200806T101031_N0214_R022_T32TNR_20200806T115620.SAFE
#> "2020-08-06 10:10:31 UTC"
#> S2A_MSIL2A_20200809T102031_N0214_R065_T32TNR_20200809T130506.SAFE
#> "2020-08-09 10:20:31 UTC"
#> S2B_MSIL2A_20200811T100559_N0214_R022_T32TNR_20200811T133733.SAFE
#> "2020-08-11 10:05:59 UTC"
# }