Learn R Programming

rstac (version 0.9.1-5)

assets_download: Downloads assets via STAC API

Description

The assets_download function downloads the assets provided by the STAC API.

Usage

assets_download(
  items,
  asset_names = NULL,
  output_dir = ".",
  overwrite = FALSE,
  items_max = Inf,
  progress = TRUE,
  fn = NULL,
  ...,
  assets_name = deprecated()
)

Value

The same STACItemCollection or STACItem object, with the link of the item pointing to the directory where the assets were saved.

Arguments

items

a STACItem or STACItemCollection object representing the result of /stac/search, /collections/{collectionId}/items or /collections/{collectionId}/items/{itemId} endpoints.

asset_names

a character with the assets names to be filtered.

output_dir

a character directory in which the assets will be saved.

overwrite

a logical if TRUE will replaced the existing file, if FALSE a warning message is shown.

items_max

a numeric corresponding how many items will be downloaded.

progress

a logical indicating if a progress bar must be shown or not. Defaults to TRUE.

fn

a function to handle the list of assets for each item. Using this function you can change the hrefs for each asset, as well as use another request verb, such as POST.

...

config parameters to be passed to GET or POST methods, such as add_headers or set_cookies.

assets_name

[Deprecated] use asset_names parameter instead.

See Also

stac_search(), items(), get_request()

Examples

Run this code
if (FALSE) {
stac("https://brazildatacube.dpi.inpe.br/stac/") %>%
  stac_search(collections = "CB4_64_16D_STK-1",
              datetime = "2019-06-01/2019-08-01") %>%
  stac_search() %>%
  get_request() %>%
  assets_download(asset_names = "thumbnail", output_dir = ".",
  overwrite = FALSE)
}

Run the code above in your browser using DataLab