knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" )
The Rwtss package is a front-end to the Web Time Series Service (WTSS) that offers time series of remote sensing data using a simple API. A WTSS server takes as input an Earth observation data cube, that has a spatial and a temporal dimension and can be multidimensional in terms of its attributes. The WTSS API has three commands, which are are (a) list_coverages, that returns a list of coverages available in the server; (b) describe_coverage, that that returns the metadata for a given coverage; (c) time_series, that returns a time series for a spatio-temporal location.
The R interface to WTSS services considers that "coverages" are equivalent to "data cubes". Data cubes rely on the fact that Earth observation satellites revisit the same place at regular intervals. Thus measures can be calibrated so that observations of the same place in different times are comparable. These calibrated observations can be organised in regular intervals, so that each measure from sensor is mapped into a three dimensional multivariate array in space-time.
The first step towards using the service is connecting to a server that supports the WTSS protocol. Currently, Brazil's National Institute for Space Research (INPE) runs such a WTSS service in the address below.
# Connect to the WTSS server at INPE Brazil wtss_inpe <- "https://brazildatacube.dpi.inpe.br/wtss/"
This operation allows clients to retrieve the capabilities provided by any server that implements WTSS. It returns a list of coverage names available in a server instance.
# Connect to the WTSS server at INPE Brazil Rwtss::list_coverages(wtss_inpe)
paste(c("MOD13Q1-6", "MYD13Q1-6", "S2-SEN2COR_10_16D_STK-1", "LC8_30_16D_STK-1", "CB4MUX_20_1M_STK-1", "LC8_30_6M_MEDSTK-1", "CB4_64_16D_STK-1", "LANDSAT-MOZ_30_1M_STK-1"))
This operation returns the metadata for a given coverage identified by its name. It includes its range in the spatial and temporal dimensions.
# Connect to the WTSS server at INPE Brazil desc <- Rwtss::describe_coverage(wtss_inpe, name = "MOD13Q1-6")
# Coverage description available in the wtss object cat("---------------------------------------------------------------------") cat("WTSS server URL = https://brazildatacube.dpi.inpe.br/wtss") cat("Cube (coverage) = MOD13Q1-6") cat("Timeline - 508 time steps") cat("start_date: 2000-02-18 end_date: 2022-03-22") cat("---------------------------------------------------------------------")
This operation requests the time series of values of a coverage attribute at a given location. Its parameters are: (a) wtss.obj: either a WTSS object (created by the operation wtss::WTSS as shown above) or a valid WTSS server URL; (b) name: Cube (coverage) name; (c) attributes: vector of band names (optional). If omitted, all bands are retrieved; (d) longitude: longitude in WGS84 coordinate system; (e)latitude: Latitude in WGS84 coordinate system; (f)start_date (optional): Start date in the format yyyy-mm-dd or yyyy-mm depending on the coverage. If omitted, the first date on the timeline is used; (g)
end_date(optional): End date in the format yyyy-mm-dd or yyyy-mm depending on the coverage. If omitted, the last date of the timeline is used; (h) To access the BDC time series it is necessary to provide a token, provide the token through the token
parameter.
To create a new BDC token, please see this tutorial.
# Request a time series from the "MOD13Q1" coverage ndvi_ts <- Rwtss::time_series(wtss_inpe, name = "MOD13Q1-6", attributes = c("NDVI", "EVI"), longitude = -45.00, latitude = -12.00, start_date = "2000-02-18", end_date = "2016-12-18", token = "YOUR-BDC-TOKEN")
library(tibble) ndvi_ts <- readRDS(file = system.file("extdata/ndvi_ts.rds", package = "Rwtss"))
ndvi_ts
The result of the operation is a tibble
which contains data and metadata. The first six columns contain the metadata: satellite, sensor, spatial and temporal information, and the coverage from where the data has been extracted. The spatial location is given in longitude and latitude coordinates for the "WGS84" ellipsoid. The time_series
column contains the time series data for each spatiotemporal location. This data is also organized as a tibble, with a column with the dates and the other columns with the values for each spectral band.
For compatibility with the sits suite of packages for satellite image time series analysis, the R interface to the WTSS packages uses the term "cube" to refer to the contents of the coverage. The time series retrieved from WTSS also include a "label" column, to be use for assigning labels to time series samples that are used to train classifiers.
# Showing the contents of a time series ndvi_ts$time_series[[1]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.