Coercing trip objects to other classes.

Function to create a SpatialLinesDataFrame from a trip object, resulting in a line segment for each implicit segment along the tracks. The object stores the start and end times, duration and the ID of the segment.

# S3 method for trip
as.ppp(X, ..., fatal)

# S3 method for trip
as.psp(x, ..., from, to)

as.track_xyt.trip(x, ..., from, to)

explode(x, ...)

Arguments

X

trip object.

...

reserved for future methods

fatal

Logical value, see Details of as.ppp

x

trip object

from

see as.psp for that method.

to

See as.psp.

Value

ppp object

psp object

SpatialLinesDataFrame

SpatialLinesDataFrame object with each individual line segment identified by start/end time and trip ID

Examples

if (FALSE) { d <- data.frame(x=1:10, y=rnorm(10), tms=Sys.time() + 1:10, id=gl(2, 5)) sp::coordinates(d) <- ~x+y ## this avoids complaints later, but these are not real track data (!) sp::proj4string(d) <- sp::CRS("+proj=laea +ellps=sphere", doCheckCRSArgs = FALSE) tr <- trip(d, c("tms", "id")) as(tr, "ppp") } if (FALSE) { d <- data.frame(x=1:10, y=rnorm(10), tms=Sys.time() + 1:10, id=gl(2, 5)) sp::coordinates(d) <- ~x+y ## this avoids complaints later, but these are not real track data (!) sp::proj4string(d) <- sp::CRS("+proj=laea +ellps=sphere", doCheckCRSArgs = FALSE) tr <- trip(d, c("tms", "id")) as.psp.trip(tr) } d <- data.frame(x=1:10, y=rnorm(10), tms=Sys.time() + 1:10, id=gl(2, 5)) sp::coordinates(d) <- ~x+y ## this avoids complaints later, but these are not real track data (!) sp::proj4string(d) <- sp::CRS("+proj=laea +ellps=sphere", doCheckCRSArgs = FALSE) tr <- trip(d, c("tms", "id")) spldf <- explode(tr) summary(tr)
#> #> Object of class trip #> tripID ("id") No.Records startTime ("tms") endTime ("tms") tripDuration #> 1 1 5 2020-10-27 23:24:21 2020-10-27 23:24:25 4 secs #> 2 2 5 2020-10-27 23:24:26 2020-10-27 23:24:30 4 secs #> tripDistance meanSpeed maxSpeed #> 1 7.289341 6560.407 9406.25 #> 2 6.861058 6174.952 10147.47 #> #> Total trip duration: 8 seconds (0 hours, 8 seconds) #> #> Derived from Spatial data: #> #> Object of class SpatialPointsDataFrame #> Coordinates: #> min max #> x 1.000000 10.000000 #> y -0.782706 2.353945 #> Is projected: TRUE #> proj4string : [+proj=laea +ellps=sphere] #> Number of points: 10 #> Data attributes: #> tms id #> Min. :2020-10-27 23:24:21 1:5 #> 1st Qu.:2020-10-27 23:24:23 2:5 #> Median :2020-10-27 23:24:25 #> Mean :2020-10-27 23:24:25 #> 3rd Qu.:2020-10-27 23:24:27 #> Max. :2020-10-27 23:24:30 #>