Learn R Programming

spacetime (version 1.2-2)

STTDF-class: Class "STTDF"

Description

A class for spatio-temporal trajectory data

Usage

# S4 method for STTDF,ltraj
coerce(from, to, strict=TRUE)
  # S4 method for ltraj,STTDF
coerce(from, to, strict=TRUE)

Arguments

from

from object

to

target class

strict

ignored

Objects from the Class

Objects of this class carry sparse (irregular) space/time data

Slots

sp:

Object of class "Spatial", containing the bounding box of all trajectories

time:

Object of class "xts", containing the temporal bounding box of all trajectories

traj:

Object of class list, each element holding an STI object reflecting a single trajectory;

data:

Object of class data.frame, which holds the data values for each feature in each trajectory

Methods

[

signature(x = "STTDF"): select trajectories, based on index, or spatial and/or temporal predicates

% \item{plot}{\code{signature(x = "Spatial", y = "missing")}: plot method % for spatial objects; does nothing but setting up a plotting region choosing % a suitable aspect if not given(see below), colouring the plot background using either a bg= argument or par("bg"), and possibly drawing axes. } % \item{summary}{\code{signature(object = "Spatial")}: summarize object}

References

http://www.jstatsoft.org/v51/i07/

Examples

Run this code
# NOT RUN {
library(sp)
m = 3# nr of trajectories
n = 100 # length of each
l = vector("list", m)
t0 = as.POSIXct("2013-05-05",tz="GMT")
set.seed(1331) # fix randomness
for (i in 1:m) {
    x = cumsum(rnorm(n))
    y = cumsum(rnorm(n))
    sp = SpatialPoints(cbind(x,y))
    #t = t0 + (0:(n-1) + (i-1)*n) * 60
    t = t0 + (0:(n-1) + (i-1)*n/2) * 60
    l[[i]] = STI(sp, t)
}
stt= STT(l)
sttdf = STTDF(stt, data.frame(attr = rnorm(n*m), id = paste("ID", rep(1:m, each=n))))
x = as(stt, "STI")
stplot(sttdf, col=1:m, scales=list(draw=TRUE))
stplot(sttdf, by = "id")
stplot(sttdf[1])
stplot(sttdf[1])

# select a trajectory that intersect with a polygon
p = Polygon(cbind(x=c(-20,-15,-15,-20,-20),y=c(10,10,15,15,10)))
pol=SpatialPolygons(list(Polygons(list(p), "ID")))
if (require(rgeos)) {
  stplot(sttdf[pol])
  names(sttdf[pol]@traj)
  stplot(sttdf[1:2],col=1:2)
  stplot(sttdf[,t0])
  stplot(sttdf[,"2013"])
  stplot(sttdf[pol,"2013"])
  is.null(sttdf[pol,t0])
}

# }

Run the code above in your browser using DataLab