Classify time series

Share:

Description

This function classifies the intervals of a time series based on the TWDTW results.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
twdtwClassify(x, ...)

## S4 method for signature 'twdtwMatches'
twdtwClassify(x, patterns.labels = NULL,
  from = NULL, to = NULL, by = NULL, breaks = NULL, overlap = 0.5,
  thresholds = Inf, fill = "unclassified")

## S4 method for signature 'twdtwRaster'
twdtwClassify(x, patterns.labels = NULL,
  thresholds = Inf, fill = 255, filepath, ...)

Arguments

x

an object of class twdtw*. This is the target time series. Usually, it is a set of unclassified time series.

...

arguments to pass to specifique methods for each twdtw* signature and other arguments to pass to writeRaster.

patterns.labels

a vector with labels of the patterns.

from

A character or Dates object in the format "yyyy-mm-dd".

to

A character or Dates object in the format "yyyy-mm-dd".

by

A character with the intevals size, e.g. "6 month".

breaks

A vector of class Dates. This replaces the arguments from, to, and by.

overlap

A number between 0 and 1. The minimum overlapping between one match and the interval of classification. Default is 0.5, i.e. an overlap minimum of 50%.

thresholds

A numeric vector the same length as patterns.labels. The TWDTW dissimilarity thresholds, i.e. the maximum TWDTW cost for consideration in the classification. Default is Inf for all patterns.labels.

fill

a character or value to fill the classification gaps. For signature twdtwTimeSeries the default is fill="unclassified", and for signature twdtwRaster the default is fill="unclassified".

filepath

A character. The path to save the raster with results. If not informed the function saves in the same directory as the input time series raster.

Value

An object of class twdtw*.

Author(s)

Victor Maus, vwmaus1@gmail.com

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Classifying time series based on TWDTW results 
ts = twdtwTimeSeries(example_ts.list)
patt = twdtwTimeSeries(patterns.list)
log_fun = logisticWeight(-0.1, 100)
time_intervals = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), by="6 month")
mat = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE)
best_mat = twdtwClassify(x=mat, breaks=time_intervals, overlap=0.5)
plot(x=best_mat, type="classification")

## Not run: 
require(parallel)
best_mat = mclapply(as.list(mat), mc.cores=4, FUN=twdtwClassify, breaks=time_intervals, overlap=0.5)
best_mat = twdtwMatches(alignments=best_mat)

## End(Not run)
## Not run: 
# Run TWDTW analysis for raster time series 
patt = yearly_patterns_mt
evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat"))
ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat"))
red = brick(system.file("lucc_MT/data/red.tif", package="dtwSat"))
blue = brick(system.file("lucc_MT/data/blue.tif", package="dtwSat"))
nir = brick(system.file("lucc_MT/data/nir.tif", package="dtwSat"))
mir = brick(system.file("lucc_MT/data/mir.tif", package="dtwSat"))
doy = brick(system.file("lucc_MT/data/doy.tif", package="dtwSat"))
timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date")
rts = twdtwRaster(evi, ndvi, red, blue, nir, mir, timeline = timeline, doy = doy)

time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), 
                    by="12 month")
log_fun = weight.fun=logisticWeight(-0.1,50)

r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, 
          filepath="~/test_twdtw", overwrite=TRUE, format="GTiff", mc.cores=3)

r_lucc = twdtwClassify(r_twdtw, format="GTiff")

plotMaps(r_lucc)


## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.