R: Obtain time series from different sources

sits_get_data {sits} | R Documentation

## Obtain time series from different sources

### 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. A sits tibble is a tibble with pre-defined columns that has the metadata and data for each time series. The columns are <longitude, latitude, start_date, end_date, label, cube, time_series>. There are many ways of retrieving time series:

- SATVEG:Retrieve data from SATVEG service using a lat/long point (see S3 method for class 'satveg_cube'), a CSV file (see S3 method for class 'csv_satveg_cube') or a SHP file (see S3 method for class 'shp_satveg_cube')

- RASTER: Retrieve data from any raster cube using a lat/long point (see S3 method for class 'raster_cube'), a CSV file (see S3 method for class 'csv_raster_cube') or a SHP file (see S3 method for class 'shp_raster_cube')

The URL and other parameters for accessing the time series services are defined in the package configuration file. This file is "config.yml". Please see the `sits_config` for more information.

Before using this service, the user should create a valid description of a data cube using the `sits_cube` function.

### Usage

    sits_get_data(cube, file = NULL, ..., multicores = 1)

    ## S3 method for class 'wtss_cube'
    sits_get_data(
      cube,
      file = NULL,
      ...,
      longitude = NULL,
      latitude = NULL,
      start_date = NULL,
      end_date = NULL,
      bands = NULL,
      label = "NoClass"
    )

    ## S3 method for class 'satveg_cube'
    sits_get_data(
      cube,
      file = NULL,
      ...,
      longitude = NULL,
      latitude = NULL,
      start_date = NULL,
      end_date = NULL,
      label = "NoClass"
    )

    ## S3 method for class 'csv_wtss_cube'
    sits_get_data(cube, file, ..., bands = NULL)

    ## S3 method for class 'csv_satveg_cube'
    sits_get_data(cube, file, ...)

    ## S3 method for class 'shp_wtss_cube'
    sits_get_data(
      cube,
      file,
      ...,
      start_date = NULL,
      end_date = NULL,
      bands = NULL,
      label = "NoClass",
      shp_attr = NULL,
      .n_shp_pol = 30
    )

    ## S3 method for class 'shp_satveg_cube'
    sits_get_data(
      cube,
      file,
      ...,
      start_date = NULL,
      end_date = NULL,
      label = "NoClass",
      shp_attr = NULL,
      .n_shp_pol = 30
    )

    ## S3 method for class 'raster_cube'
    sits_get_data(
      cube,
      file = NULL,
      ...,
      longitude = NULL,
      latitude = NULL,
      start_date = NULL,
      end_date = NULL,
      bands = NULL,
      label = "NoClass",
      impute_fn = sits_impute_linear()
    )

    ## S3 method for class 'csv_raster_cube'
    sits_get_data(
      cube,
      file,
      ...,
      bands = NULL,
      impute_fn = sits_impute_linear(),
      multicores = 1,
      .n_pts_csv = NULL
    )

    ## S3 method for class 'shp_raster_cube'
    sits_get_data(
      cube,
      file,
      ...,
      start_date = NULL,
      end_date = NULL,
      bands = NULL,
      label = "NoClass",
      impute_fn = sits_impute_linear(),
      multicores = 1,
      shp_attr = NULL,
      .n_shp_pol = 30
    )

### Arguments

`cube` | Data cube from where data is to be retrieved.
`file` | File with information on the data to be retrieved.
`...` | Other parameters to be passed for specific types.
`multicores` | Number of threads to process the time series.
`longitude` | Longitude of the chosen location.
`latitude` | Latitude of the chosen location.
`start_date` | Start of the interval for the time series in "YYYY-MM-DD" format (optional).
`end_date` | End of the interval for the time series in "YYYY-MM-DD" format (optional).
`bands` | Bands to be retrieved (optional).
`label` | Label to be assigned to the time series (optional).
`shp_attr` | Attribute in the shapefile to be used as a polygon label.
`.n_shp_pol` | Number of samples per polygon to be read (for POLYGON or MULTIPOLYGON shapefile).
`impute_fn` | Imputation function for NA values.
`.n_pts_csv` | Number of points from CSV file to be retrieved.

### Value

A tibble with the metadata and data for each time series <longitude, latitude, start_date, end_date, label, cube, time_series>.

### Author(s)

Gilberto Camara

### References

Lubia Vinhas, Gilberto Queiroz, Karine Ferreira, Gilberto Camara, Web Services for Big Earth Observation Data. In: XVII Brazilian Symposium on Geoinformatics, 2016, Campos do Jordao. Proceedings of GeoInfo 2016. Sao Jose dos Campos: INPE/SBC, 2016. p.166-177.

### Examples

    # -- Read a point in a raster data cube

    # Create a data cube based on files
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    raster_cube <- sits_cube(
        source = "LOCAL",
        name = "sinop-2014",
        origin = "BDC",
        collection = "MOD13Q1-6",
        data_dir = data_dir,
        delim = "_",
        parse_info = c("X1", "X2", "tile", "band", "date")
    )

    # read the time series of the point from the raster
    point_ts <- sits_get_data(raster_cube,
        longitude = -55.554,
        latitude = -11.525
    )

    # --- Read a set of points described by a CSV file

    # read data from a CSV file
    csv_file <- system.file("extdata/samples/samples_sinop_crop.csv",
        package = "sits"
    )
    points_csv <- sits_get_data(raster_cube, file = csv_file)

[Package sits version 0.14.0 Index]