Title: | Client for Web Time-Series Service |
---|---|
Description: | Allows remote access to satellite image time series provided by the web time series service (WTSS) available at servers such as <https://brazildatacube.dpi.inpe.br/wtss/>. The functions include listing the data sets available in WTSS servers, describing the contents of a data set, and retrieving a time series based on spatial location and temporal filters. |
Authors: | Gilberto Queiroz [aut] , Gilberto Camara [aut] , Pedro Andrade [aut] , Felipe Souza [aut, cre], Luiz Assis [aut] |
Maintainer: | Felipe Souza <[email protected]> |
License: | GPL-3 |
Version: | 0.9.2 |
Built: | 2024-11-08 04:59:13 UTC |
Source: | https://github.com/cran/Rwtss |
An R client to the web time series service (WTSS)
Implements an R interface to a 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 four commands:
'wtss': given an URL, creates a connection to a WTSS service
'list_coverages': returns a list of coverages (cubes) available in the WTSS server.
'describe_coverage': returns the metadata for a given coverage.
'time_series': returns a time series for a spatio-temporal location.
Maintainer: Felipe Souza [email protected]
Authors:
Gilberto Queiroz [email protected] (ORCID)
Gilberto Camara [email protected] (ORCID)
Pedro Andrade [email protected] (ORCID)
Luiz Assis [email protected]
Useful links:
creates a tibble to store the description of the WTSS coverage
.wtss_coverage_description(URL, cov)
.wtss_coverage_description(URL, cov)
URL |
URL of the coverage |
cov |
coverage response provided by WTSS service |
Sends a request to the WTSS server and gets a response
.wtss_get_response(request, ...)
.wtss_get_response(request, ...)
request |
valid request according to the WTSS protocol |
... |
additional parameters that can be added in httr. |
response from the server
Plots a set of time series using ggplot. This function is used for showing the same lat/long location in a series of time steps.
.wtss_ggplot_series(row, colors = "Dark2")
.wtss_ggplot_series(row, colors = "Dark2")
row |
A row of a sits tibble with the time series to be plotted. |
colors |
The set of Brewer colors to be used for plotting. |
Based on resolution, tries to guess what is the satellite.
.wtss_guess_satellite(xres)
.wtss_guess_satellite(xres)
xres |
xres of the coverage |
Satellite sensor pair
Gilberto Camara, [email protected]
Use the WTSS protocol to find out available coverages
.wtss_list_coverages(URL)
.wtss_list_coverages(URL)
URL |
URL of the WTSS service |
updated WTSS object.
Parse a JSON response from the WTSS service
.wtss_parse_json(response)
.wtss_parse_json(response)
response |
valid JSON response from the WTSS service |
parsed JSON document
Process a request
.wtss_process_request(request)
.wtss_process_request(request)
request |
valid request to the WTSS service |
parsed JSON document
The WTSS URL cannot have a trailing dash. This functions checks and removes it, if present.
.wtss_remove_trailing_dash(URL)
.wtss_remove_trailing_dash(URL)
URL |
A WTSS URL |
URL without trailing dash
Sends a request to the WTSS server and times out after 10 tries
.wtss_send_request(request, ...)
.wtss_send_request(request, ...)
request |
valid request according to the WTSS protocol |
... |
additional parameters that can be added in httr. |
response from the server
This function returns an empty tibble that contains the satellite image time series and its metadata. The columns are <longitude, latitude, start_date, end_date, label, cube, time_series>. WTSS functions produce a tibble as output.
.wtss_tibble()
.wtss_tibble()
A tibble.
Gilberto Camara, [email protected]
Processing a Time Series Result from WTSS
.wtss_time_series_processing(items)
.wtss_time_series_processing(items)
items |
Items retrieved from WTSS server |
tibble with a time series
Converts data from an instance of a zoo series to a sits tibble.
.wtss_to_tibble( ts, name, bands, longitude, latitude, start_date, end_date, cov_desc )
.wtss_to_tibble( ts, name, bands, longitude, latitude, start_date, end_date, cov_desc )
ts |
list of time series retrieved by WTSS |
name |
Name of the coverage where data comes from. |
bands |
Bands to be retrieved from the time series. |
longitude |
Longitude of the chosen location. |
latitude |
Latitude of the chosen location. |
start_date |
Starting date of the time series |
end_date |
End date of the time series |
cov_desc |
Description of the WTSS coverage |
Time series in sits tibble format.
Gilberto Camara, [email protected]
Magrittr compound assignment pipe-operator.
lhs , rhs
|
A visualisation and a function to apply to it. |
Contacts the WTSS server to describe one coverage
describe_coverage(URL, name, .print = TRUE)
describe_coverage(URL, name, .print = TRUE)
URL |
URL of the server |
name |
name of coverage |
.print |
Print the coverage description |
tibble with coverage description
## Not run: # Using external server describe_coverage("https://brazildatacube.dpi.inpe.br/wtss/", "LC8_30_16D_STK-1") ## End(Not run)
## Not run: # Using external server describe_coverage("https://brazildatacube.dpi.inpe.br/wtss/", "LC8_30_16D_STK-1") ## End(Not run)
Lists coverages available in the WTSS service
list_coverages(URL)
list_coverages(URL)
URL |
URL of the server |
vector with coverage name
## Not run: # Using external server list_coverages("https://brazildatacube.dpi.inpe.br/wtss/") ## End(Not run)
## Not run: # Using external server list_coverages("https://brazildatacube.dpi.inpe.br/wtss/") ## End(Not run)
A dataset containing a wtss tibble, with extracted time series.
data("ndvi_ts")
data("ndvi_ts")
A wtss
tibble with 388 samples. A wtss
tibble 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.
Given a tibble with a set of time series, plot them.
## S3 method for class 'wtss' plot(x, y, ..., colors = "Dark2")
## S3 method for class 'wtss' plot(x, y, ..., colors = "Dark2")
x |
object of class "wtss" |
y |
ignored |
... |
further specifications for plot. |
colors |
Color pallete to be used (based on Color Brewer - default is "Dark2"). |
Input tibble (useful for chaining functions).
Gilberto Camara, [email protected]
## Not run: # Access to external service # Read one time series from the WTSS server # plot one time series wtss_service <- "https://brazildatacube.dpi.inpe.br/wtss/" ts <- Rwtss::time_series( wtss_service, 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") plot(ts) ## End(Not run)
## Not run: # Access to external service # Read one time series from the WTSS server # plot one time series wtss_service <- "https://brazildatacube.dpi.inpe.br/wtss/" ts <- Rwtss::time_series( wtss_service, 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") plot(ts) ## End(Not run)
Retrieves the time series for a pair of coordinates
time_series( URL, name, attributes = NULL, longitude, latitude, start_date = NULL, end_date = NULL, token = NULL, ... )
time_series( URL, name, attributes = NULL, longitude, latitude, start_date = NULL, end_date = NULL, token = NULL, ... )
URL |
URL of the server |
name |
Coverage name. |
attributes |
Vector of band names. |
longitude |
Longitude in WGS84 coordinate system. |
latitude |
Latitude in WGS84 coordinate system. |
start_date |
Start date in the format yyyy-mm-dd or yyyy-mm depending on the coverage. |
end_date |
End date in the format yyyy-mm-dd or yyyy-mm depending on the coverage. |
token |
A character with token to be add in URL. |
... |
Additional parameters that can be added in httr. |
time series in a tibble format (NULL)
Gilberto Camara
## Not run: # connect to a WTSS server wtss_server <- "https://brazildatacube.dpi.inpe.br/wtss/" # retrieve a time series ndvi_ts <- Rwtss::time_series(wtss_server, "LC8_30_16D_STK-1", attributes = "NDVI", latitude = -14.31, longitude = -51.16, token = "YOUR-BDC-TOKEN") # plot the time series plot(ndvi_ts) ## End(Not run)
## Not run: # connect to a WTSS server wtss_server <- "https://brazildatacube.dpi.inpe.br/wtss/" # retrieve a time series ndvi_ts <- Rwtss::time_series(wtss_server, "LC8_30_16D_STK-1", attributes = "NDVI", latitude = -14.31, longitude = -51.16, token = "YOUR-BDC-TOKEN") # plot the time series plot(ndvi_ts) ## End(Not run)
Converts data from a wtss tibble to a time series "ts". A WTSS tibble contains data retrieved from a WTSS server. These data sets are time series with irregular intervals. Given that of many functions that use the R "ts" format, this function converts a time series (a tibble with data and metadata) to the "ts" format. Since "ts" requires regular time series, it interpolates the original irregular time series to a regular time series. To do this, the user needs to specify a period which is recognised by the "ts" format. This period can be either "month", "week", "day", "months", "weeks", "days" or 12, 52, 365. This function creates a new time series with the required frequency and intepolates the missing values using spline interpolation from the "zoo" package (zoo::na.spline).
wtss_to_ts(data, band = NULL, period = "week")
wtss_to_ts(data, band = NULL, period = "week")
data |
A sits tibble with time series. |
band |
Name of the band to be exported (optional if series has only one band) |
period |
One of c("month", "week", "day"), c("months", "weeks", "days") or c(12, 52, 365) |
A time series in the ts format.
Gilberto Camara, [email protected]
## Not run: # connect to a WTSS server wtss_service <- "https://brazildatacube.dpi.inpe.br/wtss/" # retrieve a time series ts_wtss <- Rwtss::time_series( wtss_service, "MOD13Q1-6", c("NDVI","EVI"), longitude = -45.00, latitude = -12.00, start_date = "2000-02-18", end_date = "2016-12-18", token = "YOUR-BDC-TOKEN") # convert to ts ts <- Rwtss::wtss_to_ts(ts_wtss, band = "NDVI") ## End(Not run)
## Not run: # connect to a WTSS server wtss_service <- "https://brazildatacube.dpi.inpe.br/wtss/" # retrieve a time series ts_wtss <- Rwtss::time_series( wtss_service, "MOD13Q1-6", c("NDVI","EVI"), longitude = -45.00, latitude = -12.00, start_date = "2000-02-18", end_date = "2016-12-18", token = "YOUR-BDC-TOKEN") # convert to ts ts <- Rwtss::wtss_to_ts(ts_wtss, band = "NDVI") ## End(Not run)
Converts data from a tibble to a list of a zoo series.
wtss_to_zoo(data, band = NULL)
wtss_to_zoo(data, band = NULL)
data |
A tibble with time series. |
band |
Name of the band to be exported (if NULL all bands are exported). |
List of time series in zoo format.
Gilberto Camara, [email protected]
## Not run: # retrieve a time series wtss_service <- "https://brazildatacube.dpi.inpe.br/wtss/" ts_wtss <- Rwtss::time_series( wtss_service, "MOD13Q1-6", c("NDVI","EVI"), longitude = -45.00, latitude = -12.00, start_date = "2000-02-18", end_date = "2016-12-18", token = "YOUR-BDC-TOKEN") # convert to zoo zoo.lst <- Rwtss::wtss_to_zoo(ts_wtss) ## End(Not run)
## Not run: # retrieve a time series wtss_service <- "https://brazildatacube.dpi.inpe.br/wtss/" ts_wtss <- Rwtss::time_series( wtss_service, "MOD13Q1-6", c("NDVI","EVI"), longitude = -45.00, latitude = -12.00, start_date = "2000-02-18", end_date = "2016-12-18", token = "YOUR-BDC-TOKEN") # convert to zoo zoo.lst <- Rwtss::wtss_to_zoo(ts_wtss) ## End(Not run)