This function can be used for a spatiotemporal query of S2 L2A data on AWS servers and downloads either all or specific assets found at the STAC API endpoint. Internally the function depends on the `rstac` package which makes queries to STAC endpoints very convinient. Note, currently only S2 L2A COGs can be downloaded using this function.

download_aws(
  collection = "sentinel-s2-l2a-cogs",
  assets = NULL,
  bbox = NULL,
  after = NULL,
  before = NULL,
  timeframe = "full",
  max.cloud = 100,
  max.items = 500,
  outdir = ".",
  overwrite = FALSE,
  use_aria = F,
  aria_bin = NULL,
  skip_existing = FALSE,
  max_concurrent = 4,
  max_connections = 4,
  retry = 2,
  verbose = T,
  query_only = F
)

Arguments

collection

A name of a collection. Defaults to "sentinel-s2-l2a-cogs", currently the only supported collection.

assets

A character vector indicating the assets to download, e.g. bands. Defaults to NULL which will download all available assets.

bbox

A numeric vector of lenght four indicating the spatial bounding box of the query c(xmin, ymin, xmax, ymax) in geographic coordinates. Defaults to NULL which will set the spatial extent to global, i.e. c(-180, -90, 180, 90).

after

A length one character vector in the form ` the earliest date (inclusive) included in the temporal extent.

before

A length one character vector in the form ` the latest date (inclusive) included in the temporal extent.

timeframe

A length one character vector indicating whether the query should return the complete time series between after and before or if the query should be based on seasons. Possbile values are "full" and "seasonal". Defaults to "full".

max.cloud

A length one integer indicating the maximum number of cloud cover in percent to qualify a scene for download. Defaults to "100" which will download all scenes matching the spatiotemporal extent.

max.items

A length one integer indicating the maximum number of items to return from a single query. Defaults to 500. Can be used for cases where large queries will lead to long query times. But if that is the case it is advisable to break up into small sub-queries so that the complete data can be downloaded.

outdir

A character vector of an existing directory. Defaults to the current working directory. Throws an error if the directory does not exist.

overwrite

A logical indicator indicating if present data sets in outdir should be overwritten. Defaults to FALSE.

use_aria

A logical if the aria2 downloader shall be used. Defaultes to FALSE which will download the items sequentially via GET requests. If TRUE it is expected that the argument aria_bin points towards a valid aria binary installation.

aria_bin

A charachter vector pointing to a valid aria binary.

skip_existing

A logical indicating if existing files should be removed from the download list prior to downloading with aria. Might speed up the process when a prior download was interrupted, however, when files were not downloaded completley their download is not ressumed (check for .aria files in outdir). Defaults to FALSE which means that existing files are not skipped.

max_concurrent

Maximum number of connections to the server to load a single file. Defaults to 4.

max_connections

Maximum number of parallel connections to the server to load files simoltaniously. Defaults to 4.

retry

Integer. Maximum integer of retries for erroneous downloads.

verbose

A logical indicating the verbosity.

query_only

Logical. Defaults to FALSE which means matching items are downloaded. Else matching items are returned in a list object.

Value

Nothing. This function downloads matching assets of the spatiotemporal query to the specified directory in outdir.

Author

Darius Görgen (MapTailor Geospatial Consulting GbR) info@maptailor.net
Maintainer: MAPME-Initiative contact@mapme-initiative.org
Contact Person: Dr. Johannes Schielein
Copyright: MAPME-Initiative
License: GPL-3