sits_get_data: Obtain time series from different sources

Description Usage Arguments Value Author(s) References Examples

View source: R/sits_get_data.R

Description

Retrieve a set of time series 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 two main ways of retrieving time series: 1. Using a time series service and from a data cube defined based on a set of Raster Bricks. Two time series services are available: (a) Web Time Series Service (WTSS) by INPE; (b) SATVEG service from EMBRAPA. Please see sits_services for more information on the WTSS service. The URL and other parameters for accessing 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 description of a data cube using the sits_cube 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 result is atibble with the metadata and data for each time series <longitude, latitude, start_date, end_date, label, cube, time_series>

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
sits_get_data(
  cube,
  file = NULL,
  longitude = NULL,
  latitude = NULL,
  start_date = NULL,
  end_date = NULL,
  bands = NULL,
  label = "NoClass",
  shp_attr = NULL,
  .n_shp_pol = 20,
  .n_shp_pts = Inf,
  .prefilter = "1",
  .n_start_csv = 1,
  .n_max_csv = Inf,
  .n_save = 0
)

Arguments

cube

Data cube from where data is to be retrived.

file

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

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 (for shapefiles only.

.n_shp_pol

Number of samples per polygon to be read (for POLYGON or MULTIPOLYGON shapes).

.n_shp_pts

Number of points to be read (for POINT shapes).

.prefilter

Prefilter for SATVEG cube ("0" - none, "1" - no data correction, "2" - cloud correction, "3" - no data and cloud correction).

.n_start_csv

Row on the CSV file to start reading.

.n_max_csv

Maximum number of CSV samples to be read (set to Inf to read all).

.n_save

Number of samples to save as intermediate files (used for long reads).

Value

A tibble with time series data and metadata.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
# Read a single lat long point from a WTSS server

wtss_cube <- sits_cube(service = "WTSS", name = "MOD13Q1")
point.tb <- sits_get_data (wtss_cube, longitude = -55.50563,
                                      latitude = -11.71557)
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.data")
points.tb <- sits_get_data (wtss_cube, file = csv_file)
# show the points retrieved for the WTSS server
plot(points.tb[1:3,])

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

# define a shapefile and read from the points inside it from WTSS
shp_file <- system.file("extdata/shapefiles/parcel_agriculture.shp",
                         package = "sits.data")
parcel.tb <- sits_get_data(wtss_cube, file = shp_file, .n_shp_pol = 5)

# 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.data"))
# define the timeline
data(timeline_modis_392)
# create a data cube based on the information about the files
raster_cube <- sits_cube(name = "Sinop-crop", timeline = timeline_modis_392,
                         bands = c("ndvi"), files = files)
# read the time series of the point from the raster
point_ts <- sits_get_data(raster_cube, longitude = -55.554,
                                       latitude = -11.525)
plot(point_ts)

#' # Read a CSV file in a Raster Brick
csv_file <- system.file ("extdata/samples/samples_sinop_crop.csv",
                         package = "sits.data")
points.tb <- sits_get_data (raster_cube, file = csv_file)
# show the points retrieved for the RASTER images
plot(points.tb)
}

e-sensing/sits.data documentation built on Dec. 26, 2019, 11:02 p.m.