A new method to detect a pattern called Partners in trajectories. This algorithm identifies pairs of trajecories whose objects saty together during certain periods. This method is avaliable in the TrajDataMining package. It differs from existing moving together patterns because its implementation is highly parallelizable and its clustering method is based on distance time series analysis.
library(TrajDataMining)
library(ggplot2)
library(sp)
library(magrittr)
suppressMessages(library(rgdal))
df <- data.frame(x=A1@sp@coords[,1],y=A1@sp@coords[,2])
ggplot(df,aes(x=df$x,y=df$y))+geom_path(aes(group = 1), arrow = arrow(),color='blue')+ggtitle("elephant sea Trajectory")+xlab("X")+ ylab("Y")+theme_classic()
# get the maximum distance
max <- max(A1@connections$distance)
douglasp <- douglasPeucker(A1,max)
df <- data.frame(x=douglasp@sp@coords[,1],y=douglasp@sp@coords[,2])
ggplot(df,aes(x=df$x,y=df$y))+geom_path(aes(group = 1), arrow = arrow(),color='blue')+ggtitle("Method Douglas Peucker")+xlab("X")+ ylab("Y")+theme_classic()
# get the maximum distance
sf <- speedFilter(A1,0.01)
## [1] "2008-01-23 21:32:44"
## [1] "2008-01-24 01:31:26"
## [1] "2008-01-24 03:12:00"
## [1] "2008-01-24 11:24:42"
## [1] "2008-07-21 04:30:30"
## [1] "2008-07-21 11:22:30"
## [1] "2008-07-22 01:09:49"
## [1] "2008-07-25 13:19:46"
## [1] "2008-07-28 11:40:23"
## [1] "2008-07-29 01:23:43"
## [1] "2008-07-31 09:15:41"
## [1] "2008-11-19 12:38:34"
df <- data.frame(x=sf@sp@coords[,1],y=sf@sp@coords[,2])
ggplot(df,aes(x=df$x,y=df$y))+geom_path(aes(group = 1), arrow = arrow(),color='blue')+ggtitle("Method Speed Filter")+xlab("X")+ ylab("Y")+theme_classic()
data <- FALSE
partner(A1,A2,110792,2277,0,data)
## begintime endtime id1 id2
## 1 2008-02-04 21:26:54 2008-11-11 06:58:44 1 2