Description Usage Arguments Value Note Examples
The method aggregate
performs spatio-temporal (optionally weighted) aggregation of
trajectory data over spatial or spatio-temporal geometries.
For further detailed information please see the vignette!
1 2 3 4 5 6 7 8 9 10 11 12 | ## S4 method for signature 'Track'
aggregate(x, by, FUN = mean, ..., simplify = TRUE,
use.data = TRUE, weight.points = NULL)
## S4 method for signature 'Tracks'
aggregate(x, by, FUN = mean, ..., simplify = TRUE,
use.data = TRUE, weight.points = NULL, weight.tracks = NULL)
## S4 method for signature 'TracksCollection'
aggregate(x, by, FUN = mean, ...,
simplify = TRUE, use.data = TRUE, weight.points = NULL,
weight.tracks = NULL, byID = FALSE)
|
x |
object of class |
by |
object of class |
FUN |
aggregation function used to calculate the aggregated values, optional a function that expects a vector with weights as its second argument to perform a weighted aggregation. |
... |
optional additional arguments to |
simplify |
logical, should the return object be simplified (if possible) |
use.data |
TRUE (all data), an index vector or a vector of column names, indicating which data should be considered from the data slot(s) of the trajectories object. |
weight.points |
|
weight.tracks |
|
byID |
logical, indicating if the aggregation should be performed individually for each
|
An object of class STFDF
is returned, whose data slot contains the aggregated
values for each spatio-temporal geometry.
The arguments weight.points
and weight.tracks
should just be specified,
if a function is passed to FUN
that expects a vector with weights!
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 | ## load toy example data
load(system.file("extdata","trajaggr_TestData.RData", package = "trajaggr"), verbose = FALSE)
## Aggregation over STF objects
# Aggregate Track over STF with two time intervals
# FUN = max
agg <- aggregate(Track_A1, stf_Polys_2t, FUN = max)
class(agg)
dim(stf_Polys_2t)
dim(agg)
slot(agg, "data")
# FUN = sum
agg_0 <- aggregate(Track_A1, stf_Polys_2t, FUN = sum, na.rm= TRUE)
slot(agg_0, "data")
# FUN = weighted.mean, weighted by time
agg_1 <- aggregate(Track_A1, stf_Polys_2t, FUN = weighted.mean,
weight.points = "byTime")
slot(agg_1, "data")
##
# Aggregate Tracks over STF with two time intervals
agg_2 <- aggregate(Tracks_A, stf_Polys_2t, FUN = weighted.mean, na.rm = TRUE,
weight.points = "byTime")
slot(agg_2, "data")
##
# Aggregate TracksCollection over STF with two time intervals
agg_3 <- aggregate(TrColl, stf_Polys_2t, FUN = weighted.mean, na.rm = TRUE,
weight.points = "byTime")
slot(agg_3, "data")
##
# Aggregate TracksCollection seperated by individuals over STF with two time
# intervals,
agg_3 <- aggregate(TrColl, stf_Polys_2t, FUN = weighted.mean, na.rm = TRUE,
weight.points = "byTime", byID = TRUE)
slot(agg_3, "data")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.