Learn R Programming

sits (version 1.12.0)

sits_get_data: Obtain time series from different sources

Description

Retrieve a set of time series. There are two main ways of retrieving time series: using a time series service and from a Raster Brick. Two time series services are available: (a) the Web Time Series Service (WTSS) by INPE; (b) the SATVEG service from EMBRAPA. Please see sits_info_wtss for more information on thw WTSS service. The URL and other parameters for access to the time series services are defined in the package configuration file. This file is called "config.yml". Please see the sits_config for more information.

Before using this service, the user should create a valid coverage tibble using the sits_coverage function.

The following options are available:

  1. No input file is given - it retrieves the data and metadata based on the latitude/longitude location and on the information provided by the WTSS server.

  2. The source is a CSV file - retrieves the metadata from the CSV file and the time series from the WTSS service.

  3. The source is a SHP file - retrives all points inside the shapefile from the WTSS service.

  4. The source is a RasterBrick - retrieves the point based on lat/long from the RasterBrick.

The results is a sits tibble, which has the metadata and data for each time series <longitude, latitude, start_date, end_date, label, coverage, time_series>

Usage

sits_get_data(coverage = NULL, file = NULL, longitude = NULL,
  latitude = NULL, start_date = NULL, end_date = NULL,
  bands = NULL, prefilter = "1", label = "NoClass", .n_start = 1,
  .n_max = Inf, .n_save = 0)

Arguments

coverage

A mandatory tibble with information about the coverage.

file

An optional name of a file with information on the data to be retrieved (options - CSV, SHP).

longitude

Longitude of the chosen location.

latitude

Latitude of the chosen location.

start_date

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

end_date

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

bands

An optional vector with the names of the bands to be retrieved.

prefilter

An optional string ("0" - none, "1" - no data correction, "2" - cloud correction, "3" - no data and cloud correction).

label

An optional string with the label to be assigned to the time series.

.n_start

An optional integer with the row on the CSV file to start reading.

.n_max

An optional integer with the maximum number of CSV samples to be read (set to Inf to read all).

.n_save

An optional number of samples to save as intermediate files (used for long reads).

Value

A tibble with time series data and metadata.

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. v.1. p.166-177.

Examples

Run this code
# NOT RUN {
# Read a single lat long point from a WTSS server
wtss_coverage <- sits_coverage(service = "WTSS-INPE", name = "MOD13Q1")
point.tb <- sits_get_data (wtss_coverage, longitude = -55.50563, latitude = -11.71557)
sits_plot(point.tb)

# Read a set of points defined in a CSV file from a WTSS server
csv_file <- system.file ("extdata/samples/samples_matogrosso.csv", package = "sits")
points.tb <- sits_get_data (wtss_coverage, file = csv_file)
# show the points retrieved for the WTSS server
sits_plot (points.tb[1:3,])

# Read a single lat long point from the SATVEG server
satveg_coverage <- sits_coverage(service = "SATVEG", name = "terra")
point_satveg.tb <- sits_get_data (satveg_coverage, longitude = -55.50563, latitude = -11.71557)
sits_plot(point_satveg.tb)

# define a shapefile and read from the points inside it from the WTSS service
shp_file <- system.file("extdata/shapefiles/santa_cruz_minas.shp", package = "sits")
munic.tb <- sits_get_data(coverage = wtss_coverage, file = shp_file)

# Read a point in a Raster Brick
# define the file that has the raster brick
files  <- c(system.file ("extdata/raster/mod13q1/sinop-crop-ndvi.tif", package = "sits"))
# define the timeline
data(timeline_modis_392)
# create a raster metadata file based on the information about the files
raster_cov <- sits_coverage(files = files, name = "Sinop-crop",
                            timeline = timeline_modis_392, bands = c("ndvi"))
# read the point from the raster
point_coverage <- sits_getdata(raster_cov, longitude = -55.554, latitude = -11.525)
sits_plot(point_coverage)

#' # Read a CSV file in a Raster Brick
# define the file that has the raster brick
files  <- c(system.file ("extdata/raster/mod13q1/sinop-crop-ndvi.tif", package = "sits"))
# define the timeline
data(timeline_modis_392)
# create a raster metadata file based on the information about the files
raster_cov <- sits_coverage(files = files, name = "Sinop-crop",
                            timeline = timeline_modis_392, bands = c("ndvi"))
csv_raster_file <- system.file ("extdata/samples/samples_sinop_crop.csv", package = "sits")
points.tb <- sits_get_data (raster_cov, file = csv_raster_file)
# show the points retrieved for the RASTER images
sits_plot (points.tb)
# }

Run the code above in your browser using DataLab