sits_get_data: Get time series from data cubes and cloud services

View source: R/sits_get_data.R

sits_get_dataR Documentation

Get time series from data cubes and cloud services

Description

Retrieve a set of time series from a data cube or from a time series service. Data cubes and puts it in a "sits tibble". Sits tibbles are the main structures of sits package. They contain both the satellite image time series and their metadata.

Usage

sits_get_data(
  cube,
  samples,
  ...,
  start_date = NULL,
  end_date = NULL,
  label = "NoClass",
  bands = sits_bands(cube),
  crs = 4326L,
  label_attr = NULL,
  n_sam_pol = 30L,
  pol_avg = FALSE,
  pol_id = NULL,
  multicores = 2L,
  progress = TRUE
)

## Default S3 method:
sits_get_data(cube, samples, ...)

## S3 method for class 'csv'
sits_get_data(
  cube,
  samples,
  ...,
  bands = sits_bands(cube),
  crs = 4326L,
  multicores = 2,
  progress = FALSE
)

## S3 method for class 'shp'
sits_get_data(
  cube,
  samples,
  ...,
  label = "NoClass",
  start_date = NULL,
  end_date = NULL,
  bands = sits_bands(cube),
  label_attr = NULL,
  n_sam_pol = 30,
  pol_avg = FALSE,
  pol_id = NULL,
  multicores = 2,
  progress = FALSE
)

## S3 method for class 'sf'
sits_get_data(
  cube,
  samples,
  ...,
  start_date = NULL,
  end_date = NULL,
  bands = sits_bands(cube),
  label = "NoClass",
  label_attr = NULL,
  n_sam_pol = 30,
  pol_avg = FALSE,
  pol_id = NULL,
  multicores = 2,
  progress = FALSE
)

## S3 method for class 'sits'
sits_get_data(
  cube,
  samples,
  ...,
  bands = sits_bands(cube),
  multicores = 2,
  progress = FALSE
)

## S3 method for class 'data.frame'
sits_get_data(
  cube,
  samples,
  ...,
  start_date = NULL,
  end_date = NULL,
  bands = sits_bands(cube),
  label = "NoClass",
  crs = 4326,
  multicores = 2,
  progress = FALSE
)

Arguments

cube

Data cube from where data is to be retrieved. (tibble of class "raster_cube").

samples

Location of the samples to be retrieved. Either a tibble of class "sits", an "sf" object, the name of a shapefile or csv file, or a data.frame with columns "longitude" and "latitude".

...

Specific parameters for specific cases.

start_date

Start of the interval for the time series - optional (Date in "YYYY-MM-DD" format).

end_date

End of the interval for the time series - optional (Date in "YYYY-MM-DD" format).

label

Label to be assigned to the time series (optional) (character vector of length 1).

bands

Bands to be retrieved - optional (character vector).

crs

Default crs for the samples (character vector of length 1).

label_attr

Attribute in the shapefile or sf object to be used as a polygon label. (character vector of length 1).

n_sam_pol

Number of samples per polygon to be read for POLYGON or MULTIPOLYGON shapefiles or sf objects (single integer).

pol_avg

Logical: summarize samples for each polygon?

pol_id

ID attribute for polygons (character vector of length 1)

multicores

Number of threads to process the time series (integer, with min = 1 and max = 2048).

progress

Logical: show progress bar?

Value

A tibble of class "sits" with set of time series <longitude, latitude, start_date, end_date, label, cube, time_series>.

Note

There are four ways of specifying data to be retrieved using the samples parameter: (a) CSV file: a CSV file with columns longitude, latitude, start_date, end_date and label for each sample; (b) SHP file: a shapefile in POINT or POLYGON geometry containing the location of the samples and an attribute to be used as label. Also, provide start and end date for the time series; (c) sits object: A sits tibble; (d) sf object: An link[sf]{sf} object with POINT or POLYGON geometry; (e) data.frame: A data.frame with with mandatory columns longitude and latitude.

Author(s)

Gilberto Camara

Examples

if (sits_run_examples()) {
    # reading a lat/long from a local cube
    # create a cube from local files
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    raster_cube <- sits_cube(
        source = "BDC",
        collection = "MOD13Q1-6",
        data_dir = data_dir
    )
    samples <- tibble::tibble(longitude = -55.66738, latitude = -11.76990)
    point_ndvi <- sits_get_data(raster_cube, samples)
    #
    # reading samples from a cube based on a  CSV file
    csv_file <- system.file("extdata/samples/samples_sinop_crop.csv",
        package = "sits"
    )
    points <- sits_get_data(cube = raster_cube, samples = csv_file)

    # reading a shapefile from BDC (Brazil Data Cube)
    bdc_cube <- sits_cube(
            source = "BDC",
            collection = "CBERS-WFI-16D",
            bands = c("NDVI", "EVI"),
            tiles = c("007004", "007005"),
            start_date = "2018-09-01",
            end_date = "2018-10-28"
    )
    # define a shapefile to be read from the cube
    shp_file <- system.file("extdata/shapefiles/bdc-test/samples.shp",
            package = "sits"
    )
    # get samples from the BDC based on the shapefile
    time_series_bdc <- sits_get_data(
        cube = bdc_cube,
        samples = shp_file
    )
}


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