| s2ts | R Documentation |
s2tsClass used for {sen2rts} time series.
s2ts(value, date, id = NA, qa, orbit, sensor, rawval, ...)
as.s2ts(x, ...)
value |
(mandatory) Vector with the values ("y") of the time series. |
date |
(mandatory) Vector (of the same length of |
id |
(optional) Vector (of the same length of |
qa |
(optional) Vector (of the same length of |
orbit |
(optional) Vector (of the same length of |
sensor |
(optional) Vector (of the same length of |
rawval |
(optional) Vector (of the same length of |
... |
Additional vectors to be passed.
Each additional argument is threated as an additional element of the output
list in case it is of the same length of |
x |
Input element to be converted to |
Some specific methods for this class are defined.
<s2ts_obj>$value returns a data.table with the values for each date,
in wide format.
<s2ts_obj>$date returns a vector with the dates.
<s2ts_obj>$id returns a vector with the unique ID values.
<s2ts_obj>$qa returns a data.table with the quality assessment values
for each date, in wide format.
<s2ts_obj>$rawval returns a data.table with the rawval values for
each date, in wide format.
<s2ts_obj>[[<idname>]] returns a subsampled s2ts containing only
the values of the provided ID.
Notice that since $ and [[ methods are defined, the syntaxes
<s2ts_obj>$<fieldname> and <s2ts_obj>[["<fieldname>"]]
can not be used (use instead <s2ts_obj>[,<fieldname>]).
The output time series in s2ts format.
This is a format derived from data.table, containing the mandatory columns
id, date, value, and additional ones among which
qa, orbit, sensor and rawval (see the arguments in this help for
their meanings).
The optional attribute gen_by provides information about the function
which generated the object (if provided).
Luigi Ranghetti, PhD (2020) luigi@ranghetti.info
## Create a s2ts object from raw
library(sen2r)
sample_dt <- sen2r::s2_dop(
timewindow = c("2020-01-01", "2020-01-31"),
s2_orbit = 22
)
sample_dt$ndvi <- runif(nrow(sample_dt), 0, 1)
sample_dt$qa <- sqrt(sample_dt$ndvi)
# Minimum example (including dates and values)
s2ts(value = sample_dt$ndvi, date = sample_dt$date, id = "1")
# Example with additional information (including quality flags)
sample_ts <- s2ts(
value = sample_dt$ndvi,
date = sample_dt$date,
id = "1",
qa = sample_dt$qa,
sensor = sample_dt$mission
)
sample_ts
# Extract s2ts content
as.list(sample_dt) # convert in list (unclass)
sample_ts$date # extract dates
sample_ts$id # extract IDs
sample_ts$value # extract values
sample_ts$qa # extract quality values
sample_ts$rawval # extract raw values (for smooth_s2ts() and fill_s2ts() outputs)
# Load sample data generated by sen2rts functions
data(ts_raw) # generated by extract_s2ts()
data(ts_smoothed) # generated by smooth_s2ts()
data(ts_filled) # generated by fill_s2ts()
# Visualise data
print(ts_raw, topn = 5)
print(ts_smoothed, topn = 5)
print(ts_raw, topn = 5)
# See which function generated a s2ts object
attr(ts_raw, "gen_by")
attr(ts_smoothed, "gen_by")
attr(ts_filled, "gen_by")
# Convert in data frames or data tables
df_raw <- as.data.frame(ts_raw)
head(df_raw)
df_smoothed <- as.data.frame(ts_smoothed)
head(df_smoothed)
df_filled <- as.data.frame(ts_filled)
head(df_filled)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.