Learn R Programming

sen2r (version 1.5.3)

s2_list: Retrieve list of available S2 products.

Description

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

Usage

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,
  tmpdir = NA,
  output_type = "deprecated"
)

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.

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. Available options are "scihub" (ESA Sentinel Hub) and "gcloud" (Google Cloud). Default is "scihub", meaning that only ESA Sentinel Hub is considered. In case of multiple values, they are used in order of priority. If availability = "check", products on LTA are always left as last choice. See also the section "Details".

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). If not provided, "ignore" is the default value unless server = c("scihub","gcloud") (in which case "check" is used).

tmpdir

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

output_type

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

Author

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

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

Details

By default, SAFE archives are searched on ESA Sentinel Hub (argument server = "scihub"), which is the faster and stable option. After the reduction of the retention time to 30 days, it is highly probable that products older then 30 days will not be found online (see https://github.com/ranghetti/sen2r/issues/408). Moreover, after ordering them from Long Term Archive (LTA), in several cases corrupted archives are obtained (see https://github.com/ranghetti/sen2r/issues/406, and refer to this reference for details about the ESA LTA policy).

To avoid this problems, the research and download from Google Cloud was recently implemented. Users can set server = "gcloud" to use this data exclusively, or server = c("scihub", "gcloud"), availability = "check" to search for products available on SciHub first, or on Google Cloud subsequently. 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).

Searching and downloading from Google Cloud is an experimental feature; in case of bugs, report them at https://github.com/ranghetti/sen2r/issues.

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. tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473"), URL: https://sen2r.ranghetti.info/.

Examples

Run this code
# \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)
# Print the dates of the retrieved products
safe_getMetadata(example_s2_list, "sensing_datetime")

# 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)
# Print the dates of the retrieved products
safe_getMetadata(example_s2_list, "sensing_datetime")

# }

Run the code above in your browser using DataLab