Learn R Programming

dtwSat (version 0.2.8)

getTimeSeries: Get time series from twdtw* objects

Description

Get time series from objects of class twdtw*.

Usage

# S4 method for twdtwTimeSeries
getTimeSeries(object, labels = NULL)

# S4 method for twdtwMatches getTimeSeries(object, labels = NULL)

# S4 method for twdtwMatches getPatterns(object, labels = NULL)

# S4 method for twdtwRaster getTimeSeries(object, y, labels = NULL, proj4string = NULL, id.labels = NULL)

Value

An object of class twdtwTimeSeries.

a list with TWDTW results or an object twdtwTimeSeries-class.

Arguments

object

an object of class twdtw*.

labels

character vector with time series labels. For signature twdtwRaster this argument can be used to set the labels for each sample in y, or it can be combined with id.labels to select samples with a specific label.

y

a data.frame whose attributes are: longitude, latitude, the start ''from'' and the end ''to'' of the time interval for each sample. This can also be a SpatialPointsDataFrame whose attributes are the start ''from'' and the end ''to'' of the time interval. If missing ''from'' and/or ''to'', they are set to the time range of the object.

proj4string

projection string, see CRS-class. Used if y is a data.frame.

id.labels

a numeric or character with an column name from y to be used as sample labels. Optional.

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)
getTimeSeries(ts, 2)
# Getting time series from objects of class twdtwTimeSeries
ts = twdtwTimeSeries(MOD13Q1.ts.list)
patt = twdtwTimeSeries(MOD13Q1.patterns.list)
mat = twdtwApply(x=ts, y=patt, keep=TRUE, legacy=TRUE)
getTimeSeries(mat, 2)

## This example creates a twdtwRaster object and extract 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)

# Location and time range 
ts_location = data.frame(longitude = -55.96957, latitude = -12.03864, 
                         from = "2007-09-01", to = "2013-09-01")
prj_string = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

# Extract time series 
ts = getTimeSeries(rts, y = ts_location, proj4string = prj_string)
 
autoplot(ts[[1]], facets = NULL) + xlab("Time") + ylab("Value")

Run the code above in your browser using DataLab