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,
  multicores = 2L,
  output_dir,
  progress = TRUE
)

Arguments

cube

A data cube (class "raster_cube")

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.

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,
    )
}


e-sensing/sits documentation built on Jan. 28, 2024, 6:05 a.m.