sits_cube_copy: Copy the images of a cube to a local directory

View source: R/sits_cube_copy.R

sits_cube_copyR Documentation

Copy the images of a cube to a local directory

Description

This function downloads the images of a cube in parallel. A region of interest (roi) can be provided to crop the images and a resolution (res) to resample the bands.

Usage

sits_cube_copy(
  cube,
  ...,
  roi = NULL,
  res = NULL,
  n_tries = 3,
  multicores = 2L,
  output_dir,
  progress = TRUE
)

Arguments

cube

A data cube (class "raster_cube")

...

Additional parameters to httr package.

roi

Region of interest. Either an sf_object, a shapefile, or a bounding box vector with named XY values ("xmin", "xmax", "ymin", "ymax") or named lat/long values ("lon_min", "lat_min", "lon_max", "lat_max").

res

An integer value corresponds to the output spatial resolution of the images. Default is NULL.

n_tries

Number of tries to download the same image. Default is 3.

multicores

Number of cores for parallel downloading (integer, min = 1, max = 2048).

output_dir

Output directory where images will be saved. (character vector of length 1).

progress

Logical: show progress bar?

Value

Copy of input data cube (class "raster cube").

Examples

if (sits_run_examples()) {
    # Creating a sits cube from BDC
    bdc_cube <- sits_cube(
        source = "BDC",
        collection = "CBERS-WFI-16D",
        tiles = c("007004", "007005"),
        bands = c("B15", "CLOUD"),
        start_date = "2018-01-01",
        end_date = "2018-01-12"
    )
    # Downloading images to a temporary directory
    cube_local <- sits_cube_copy(
        cube = bdc_cube,
        output_dir = tempdir(),
        roi = c(
            lon_min = -46.5,
            lat_min = -45.5,
            lon_max = -15.5,
            lat_max = -14.6
        ),
        multicores = 2L,
        res = 250,
    )
}


sits documentation built on Sept. 11, 2024, 6:36 p.m.