Learn R Programming

dtwSat (version 0.2.8)

subset: Subset time series

Description

Get subsets from objects of class twdtw*.

Usage

# S4 method for twdtwTimeSeries
subset(x, labels = NULL)

# S4 method for twdtwMatches subset(x, timeseries.labels = NULL, patterns.labels = NULL, k = NULL)

# S4 method for twdtwRaster subset(x, e = NULL, layers = NULL)

Value

An object of class twdtw*.

Arguments

x

An objects of class twdtw*.

labels

A character vector with time series labels.

timeseries.labels

a vector with labels of the time series.

patterns.labels

a vector with labels of the patterns.

k

A positive integer. The index of the last alignment to include in the subset.

e

An extent object, or any object from which an Extent object can be extracted. See crop for details.

layers

A vector with the names of the twdtwRaster object to include in the subset.

Author

Victor Maus, vwmaus1@gmail.com

References

Maus:2019dtwSat

Maus:2016dtwSat

See Also

twdtwRaster-class, twdtwTimeSeries-class, and twdtwMatches-class

Examples

Run this code
# Getting time series from objects of class twdtwTimeSeries
ts = twdtwTimeSeries(MOD13Q1.ts.list)
ts = subset(ts, 2)
ts
# Getting time series from objects of class twdtwTimeSeries
patt = twdtwTimeSeries(MOD13Q1.patterns.list)
mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100), 
                 keep=TRUE, legacy=TRUE)
mat = subset(mat, k=4)

## This example creates a twdtwRaster object and extracts time series from it. 

# Creating objects of class twdtwRaster with evi and ndvi time series 
evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat"))
ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat"))
timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date")
rts = twdtwRaster(evi, ndvi, timeline=timeline)

rts_evi = subset(rts, layers="evi")

field_samples = read.csv(system.file("lucc_MT/data/samples.csv", package="dtwSat"))
prj_string = scan(system.file("lucc_MT/data/samples_projection", package="dtwSat"), 
                  what = "character")

# Extract time series 
ts_evi = getTimeSeries(rts_evi, y = field_samples, proj4string = prj_string)

# Subset all labels = "Forest"
ts_forest = subset(ts_evi, labels="Forest")

Run the code above in your browser using DataLab