Title: | Classes and Methods for Trajectory Data |
---|---|
Description: | Classes and methods for trajectory data, with support for nesting individual Track objects in track sets (Tracks) and track sets for different entities in collections of Tracks. Methods include selection, generalization, aggregation, intersection, simulation, and plotting. |
Authors: | Edzer Pebesma [aut, cre] , Benedikt Klus [aut], Benedikt Graeler [ctb], Nikolai Gorte [ctb], Mehdi Moradi [aut] |
Maintainer: | Edzer Pebesma <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.2-9 |
Built: | 2024-11-02 05:33:27 UTC |
Source: | https://github.com/edzer/trajectories |
Trajectory, locally stored, from envirocar.org, see example below how it was imported
data(A3)
data(A3)
library(spacetime) data(A3) dim(A3) # see demo(A3) to see how A3 was fetched, and created from the web service
library(spacetime) data(A3) dim(A3) # see demo(A3) to see how A3 was fetched, and created from the web service
Convert a "Tracks" object to a list of tracks
## S3 method for class 'Tracks' as.list(x,...)
## S3 method for class 'Tracks' as.list(x,...)
x |
an object of class "Tracks" |
... |
passed to arguments of as.list |
Mohammad Mehdi Moradi <[email protected]>
rTrack, rTracks, rTracksCollection, as.list
x <- rTracks() as.list(x)
x <- rTracks() as.list(x)
Convert a "TracksCollection" object to a list of tracks
## S3 method for class 'TracksCollection' as.list(x,...)
## S3 method for class 'TracksCollection' as.list(x,...)
x |
an object of class "TracksCollection" |
... |
passed to arguments of as.list |
Mohammad Mehdi Moradi <[email protected]>
rTrack, rTracks, rTracksCollection, as.list
x <- rTracksCollection() as.list(x)
x <- rTracksCollection() as.list(x)
Function as.Track accepts converts x,y coordinates and thier corresponding time/date to an object of class Track. It can also accepts covariates for the corresponding locations, covariates must be a dataframe with some columns and length of each column is equal to length of x,y,t.
as.Track(x,y,t,covariate)
as.Track(x,y,t,covariate)
x |
x coordinate. |
y |
y coordinate. |
t |
corresponding time and date of x,y. |
covariate |
additional information. |
An object of class "Track" can be created by some geographical locations and corresponding time/dates. Function as.Track converts locations and dates/times to an object of class "Track". time/date should be from class "POSIXct" "POSIXt". See example below.
An object of class "Track".
Mohammad Mehdi Moradi <[email protected]>
x <- runif(10,0,1) y <- runif(10,0,1) date <- seq(as.POSIXct("2015-1-1 0:00"), as.POSIXct("2015-1-1 9:00"), by = "hour") Z <- as.Track(x,y,date) plot(Z)
x <- runif(10,0,1) y <- runif(10,0,1) date <- seq(as.POSIXct("2015-1-1 0:00"), as.POSIXct("2015-1-1 9:00"), by = "hour") Z <- as.Track(x,y,date) plot(Z)
Converting a list of Track objects to a list of marked point patterns. Each mark shows the length of movement.
as.Track.arrow(X,timestamp,epsilon=epsilon)
as.Track.arrow(X,timestamp,epsilon=epsilon)
X |
A list of Track objects |
timestamp |
based on secs, mins,... |
epsilon |
(optional) movements with length less than epsilon are not considered in the calculation |
Converting a list of Track objetcs to a list of marked point patterns. Marks show the length of movement with respect to the previous location.
a list of marked point patterns.
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Y <- as.Track.arrow(X,timestamp="120 secs") }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Y <- as.Track.arrow(X,timestamp="120 secs") }
This function converts a list of Tracks to a list of point patterns (class "ppp")
as.Track.ppp(X,timestamp)
as.Track.ppp(X,timestamp)
X |
a list of Track objects |
timestamp |
based on secs, mins,... |
as.Track.ppp converts a list of Track objetcs to a list of ppp objetcs.
A list of point patterns, objects of class "ppp".
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Y <- as.Track.ppp(X,timestamp="120 secs") }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Y <- as.Track.ppp(X,timestamp="120 secs") }
Fit arima models to objects of class "Track".
auto.arima.Track(X, ...)
auto.arima.Track(X, ...)
X |
an object of class "Track" |
... |
passed to arguments of auto.arima |
This fita arima models to the x,y locations of objects of class "Track".
an object of class "ArimaTrack"
Mohammad Mehdi Moradi <[email protected]>
if (require(forecast)) { X <- rTrack() auto.arima.Track(X) }
if (require(forecast)) { X <- rTrack() auto.arima.Track(X) }
This measures the average of pairwise distances between tracks over time.
avedistTrack(X,timestamp)
avedistTrack(X,timestamp)
X |
a list of some objects of class "Track" |
timestamp |
timestamp to calculate the pairwise distances between tarcks |
This function calculates the average pairwise distance between a list of tracks according to a given timestamp.
An object of class "distrack". It can be plotted over time.
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } ave <- avedistTrack(X,timestamp = "120 secs") plot(ave,type="l") }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } ave <- avedistTrack(X,timestamp = "120 secs") plot(ave,type="l") }
This returns the average movements of a lits of objects of class "Track" over time.
avemove(X,timestamp,epsilon=epsilon)
avemove(X,timestamp,epsilon=epsilon)
X |
a list of some objects of class Track |
timestamp |
timestamp to calculate the pairwise distances between tarcks |
epsilon |
(optional) movements with length less than epsilon are not considered in the calculation |
when analysying a list of tracks, avemove calculate the average of movements based on given timestamp.
an object of class "numeric" or "arwlen".
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } avemove(X,timestamp = "30 secs") }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } avemove(X,timestamp = "30 secs") }
Computes the chimaps, corresponding to a list of objects of class "Track". chimaps are based on the discrepancy between computed and expected intensity in a given location.
chimaps(X,timestamp,rank,...)
chimaps(X,timestamp,rank,...)
X |
A list of Track objects |
timestamp |
based on secs,mins,... |
rank |
a number between one and the length of corresponding time sequance which is created based on given timestamp. |
... |
passed to arguments of density.Track |
[estimated intensity - expected intensity] / sqrt(expected intensity).
an image of class "im".
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } chimaps(X, timestamp = "180 secs",rank = 2) }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } chimaps(X, timestamp = "180 secs",rank = 2) }
Track
Calculates distances between two tracks for the overlapping time interval.
## S4 method for signature 'Track' compare(tr1, tr2)
## S4 method for signature 'Track' compare(tr1, tr2)
tr1 |
An object of class |
tr2 |
An object of class |
A difftrack object. Includes both tracks extended with additional points for the timestamps of the other track. Also includes SpatialLines representing the distances between the tracks.
Nikolai Gorte <[email protected]>
## example tracks library(sp) library(xts) data(A3) track2 <- A3 index(track2@time) <- index(track2@time) + 32 track2@sp@coords <- track2@sp@coords + 0.003 ## compare and plot difftrack <- compare(A3, track2) plot(difftrack)
## example tracks library(sp) library(xts) data(A3) track2 <- A3 index(track2@time) <- index(track2@time) + 32 track2@sp@coords <- track2@sp@coords + 0.003 ## compare and plot difftrack <- compare(A3, track2) plot(difftrack)
obtain ranges of space and time coordinates
## S3 method for class 'Track' cut(x, breaks, ..., include.lowest = TRUE, touch = TRUE) ## S3 method for class 'Tracks' cut(x, breaks, ...) ## S3 method for class 'TracksCollection' cut(x, breaks, ...)
## S3 method for class 'Track' cut(x, breaks, ..., include.lowest = TRUE, touch = TRUE) ## S3 method for class 'Tracks' cut(x, breaks, ...) ## S3 method for class 'TracksCollection' cut(x, breaks, ...)
x |
object of class |
breaks |
define the breaks; see cut |
... |
passed down to Tracks and Track methods, then to cut |
include.lowest |
see cut |
touch |
logical; if FALSE, Track objects will be formed from unique sets of points, meaning that gaps between two consecutive Track objects will arise; if FALSE, the first point from each next track is copied, meaning that sets of Track are seamless. |
sub-trajectories can be invalid, if they have only one point, and are ignored. This
can happen at the start only if touch=FALSE
, and at the end in any case.
The cut
method applied to a Track
object cuts the track in pieces, and
hence returns a Tracks
object. cut.Tracks
returns a Tracks
object,
cut.TracksCollection
returns a TracksCollection
.
# example might take too long for CRAN checks data(storms) dim(storms) dim(cut(storms, "week", touches = FALSE)) # same number of geometries dim(cut(storms, "week")) # increase of geometries = increase of tracks
# example might take too long for CRAN checks data(storms) dim(storms) dim(cut(storms, "week", touches = FALSE)) # same number of geometries dim(cut(storms, "week")) # increase of geometries = increase of tracks
Estimating the intensity of a list of tracks.
## S3 method for class 'list' density(x, timestamp,...)
## S3 method for class 'list' density(x, timestamp,...)
x |
a list of "Track" objects, an object of class "Tracks" or "TracksCollection" |
timestamp |
based on secs, mins, ... |
... |
passed to arguments of density.ppp |
This estimate the average intensity function of moving objects over time. Bandwidth selection methods such as bw.diggle, bw.scott and bw.ppl can be passed to this density.list.
an image of class "im".
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.explore)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } density(X, timestamp = "180 secs") }
if (require(spatstat.explore)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } density(X, timestamp = "180 secs") }
Class that represents differences between two Track objects.
Objects can be created by calls of the form new("difftrack", ...)
.
Objects of class difftrack
contain 2 objects of class Track
extended with points for timestamps of the other track and 2
SpatialLinesDataFrame conataining the the lines and distances between tracks.
track1
:Extended track1
track2
:Extended track2
conns1
:Lines between the original track1 and the new points on track2
conns2
:Lines between the original track2 and the new points on track1
signature(x = "difftrack", y = "missing")
: plot a difftrack
Nikolai Gorte <[email protected]>
showClass("difftrack") ## example tracks library(sp) library(xts) data(A3) track2 <- A3 index(track2@time) <- index(track2@time) + 32 track2@sp@coords <- track2@sp@coords + 0.003 ## compare and plot difftrack <- compare(A3, track2) plot(difftrack) ## space-time cube of the difftrack ## Not run: stcube(difftrack) ## End(Not run)
showClass("difftrack") ## example tracks library(sp) library(xts) data(A3) track2 <- A3 index(track2@time) <- index(track2@time) + 32 track2@sp@coords <- track2@sp@coords + 0.003 ## compare and plot difftrack <- compare(A3, track2) plot(difftrack) ## space-time cube of the difftrack ## Not run: stcube(difftrack) ## End(Not run)
Tracks
objectsCalculates a distance matrix with distances for each pair of tracks.
## S4 method for signature 'Tracks,Tracks' dists(tr1, tr2, f, ...)
## S4 method for signature 'Tracks,Tracks' dists(tr1, tr2, f, ...)
tr1 |
An object of class |
tr2 |
An object of class |
f |
A function to calculate distances. Default is |
... |
Additional parameters passed to |
f
can be any function applicable to a numerical vector or frechetDist.
A matrix with distances between each pair of tracks or NA
if they don't overlap in time.
## example tracks library(sp) library(xts) data(A3) track2 <- A3 index(track2@time) <- index(track2@time) + 32 track2@sp@coords <- track2@sp@coords + 0.003 ## create Tracks objects tracks1 <- Tracks(list(A3, track2)) tracks2 <- Tracks(list(track2, A3)) ## calculate distances ## Not run: dists(tracks1, tracks2) dists(tracks1, tracks2, sum) dists(tracks1, tracks2, frechetDist) ## End(Not run)
## example tracks library(sp) library(xts) data(A3) track2 <- A3 index(track2@time) <- index(track2@time) + 32 track2@sp@coords <- track2@sp@coords + 0.003 ## create Tracks objects tracks1 <- Tracks(list(A3, track2)) tracks2 <- Tracks(list(track2, A3)) ## calculate distances ## Not run: dists(tracks1, tracks2) dists(tracks1, tracks2, sum) dists(tracks1, tracks2, frechetDist) ## End(Not run)
Track
Downsamples a Track
to the size (amount of points) of another Track
.
## S4 method for signature 'Track' downsample(track1, track2)
## S4 method for signature 'Track' downsample(track1, track2)
track1 |
|
track2 |
Reference |
A Track
object. The downsampled track1.
Nikolai Gorte <[email protected]>
Compute the discrete Frechet distance between two Track
objects.
## S4 method for signature 'Track' frechetDist(track1, track2)
## S4 method for signature 'Track' frechetDist(track1, track2)
track1 |
An object of class |
track2 |
An object of class |
Discrete Frechet distance.
Nikolai Gorte <[email protected]>
http://en.wikipedia.org/wiki/Fr\'echet_distance
Track
, Tracks
and TracksCollection
Generalize objects of class Track
, Tracks
and TracksCollection
.
## S4 method for signature 'Track' generalize(t, FUN = mean, ..., timeInterval, distance, n, tol, toPoints) ## S4 method for signature 'Tracks' generalize(t, FUN = mean, ...) ## S4 method for signature 'TracksCollection' generalize(t, FUN = mean, ...)
## S4 method for signature 'Track' generalize(t, FUN = mean, ..., timeInterval, distance, n, tol, toPoints) ## S4 method for signature 'Tracks' generalize(t, FUN = mean, ...) ## S4 method for signature 'TracksCollection' generalize(t, FUN = mean, ...)
t |
An object of class |
FUN |
The generalization method to be applied. Defaults to |
timeInterval |
(lower limit) time interval to split Track into segments |
distance |
(lower limit) distance to split Track into segments |
n |
number of points to form segments |
tol |
tolerance passed on to st_simplify, to generalize segments using the Douglas-Peucker algorithm. |
toPoints |
keep mid point rather than forming SpatialLines segments |
... |
Additional arguments passed to FUN |
An object of class Track
, Tracks
or TracksCollection
.
Estimate the variability area of K-function of a list of tracks.
Kinhom.Track(X,timestamp, correction=c("border", "bord.modif", "isotropic", "translate"),q, sigma=c("default","bw.diggle","bw.ppl"," bw.scott"),...)
Kinhom.Track(X,timestamp, correction=c("border", "bord.modif", "isotropic", "translate"),q, sigma=c("default","bw.diggle","bw.ppl"," bw.scott"),...)
X |
A list of Track objects |
timestamp |
based on secs,mins,... |
correction |
the type of correction to be used in computing K-function |
q |
(optional) a numeric value between 0 and 1. quantile to be applied to calculate the variability area |
sigma |
method to be used in computing intensity function |
... |
passed to the arguments of Kinhom |
This calculates the variability area of K-function over time. If sigma=default, it calculates the variability area using the defaults of Kinhom, otherwise it first estimate the intensity function using the given sigma as bandwidth selection method and then using the estimated intensity function, it estimates the variability area.
an object of class "KTrack".
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat)) { X <- list() for(i in 1:50){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Kinhom.Track(X, timestamp = "180 secs") }
if (require(spatstat)) { X <- list() for(i in 1:50){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Kinhom.Track(X, timestamp = "180 secs") }
Pair correlation funcrion of trajectory pattern
pcfinhom.Track(X,timestamp,correction = c("translate", "Ripley"),q, sigma=c("default","bw.diggle","bw.ppl","bw.scott"),...)
pcfinhom.Track(X,timestamp,correction = c("translate", "Ripley"),q, sigma=c("default","bw.diggle","bw.ppl","bw.scott"),...)
X |
A list of Track objects |
timestamp |
based on secs,mins,... |
correction |
the type of correction to be used in computing pair correlation function |
q |
(optional) a numeric value between 0 and 1. quantile to be applied to calculate the variability area |
sigma |
method to be used in computing intensity function |
... |
passed to the arguments of pcfinhom |
This calculates the variability area of pair correlation function over time. If sigma=default, it calculates the variability area using the defaults of pcfinhom, otherwise it first estimate the intensity function using the given sigma as bandwidth selection method and then using the estimated intensity function, it estimates the variability area.
an object of class "gTrack"
Mohammad Mehdi Moradi <[email protected]>
rTrack, as.Track.ppp, pcfinhom
if (require(spatstat.explore)) { X <- list() for(i in 1:100){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } g <- pcfinhom.Track(X,timestamp = "180 sec") plot(g) }
if (require(spatstat.explore)) { X <- list() for(i in 1:100){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } g <- pcfinhom.Track(X,timestamp = "180 sec") plot(g) }
Methods for class "arwlen"
## S3 method for class 'arwlen' plot(x, ...)
## S3 method for class 'arwlen' plot(x, ...)
x |
an object of class "arwlen" |
... |
passed on to plot |
a plot.
Mohammad Mehdi Moradi <[email protected]>
avemove
The plot method for "distrack" objects.
## S3 method for class 'distrack' plot(x, ...)
## S3 method for class 'distrack' plot(x, ...)
x |
an object of class "distrack" |
... |
ignored |
This plots an object of class "distrack".
Mohammad Mehdi Moradi <[email protected]>
plot method
## S3 method for class 'gTrack' plot(x, type = "l", col = "grey70",cex=1,line=2.2, ...)
## S3 method for class 'gTrack' plot(x, type = "l", col = "grey70",cex=1,line=2.2, ...)
x |
an object of class "gTrack" |
type |
line type |
col |
line color |
cex |
used for size of legend |
line |
specifying a value for line overrides the default placement of labels, and places them this many lines outwards from the plot edge |
... |
passed on to plot |
Mohammad Mehdi Moradi <[email protected]>
Methods for class "KTrack"
## S3 method for class 'KTrack' plot(x, type = "l", col = "grey70",cex=1,line=2.2, ...)
## S3 method for class 'KTrack' plot(x, type = "l", col = "grey70",cex=1,line=2.2, ...)
x |
an object of class KTrack |
type |
line type |
col |
color |
cex |
used for size of legend |
line |
specifying a value for line overrides the default placement of labels, and places them this many lines outwards from the plot edge |
... |
passed on to plot |
plotting the variability area of K-function of a list of tracks.
a plot.
Mohammad Mehdi Moradi <[email protected]>
print method.
## S3 method for class 'ArimaTrack' print(x, ...)
## S3 method for class 'ArimaTrack' print(x, ...)
x |
an object of class "ArimaTrack" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
to print an object of class "arwlen".
## S3 method for class 'arwlen' print(x,...)
## S3 method for class 'arwlen' print(x,...)
x |
an object of class "arqlen" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
This is a method for class "distrack".
## S3 method for class 'distrack' print(x,...)
## S3 method for class 'distrack' print(x,...)
x |
an object of class "distrack" |
... |
ignored |
This is a method for class "distrack".
See the documentation on the corresponding generic function.
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } ave <- avedistTrack(X,timestamp = "30 secs") plot(ave,type="l") }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } ave <- avedistTrack(X,timestamp = "30 secs") plot(ave,type="l") }
print method.
## S3 method for class 'gTrack' print(x,...)
## S3 method for class 'gTrack' print(x,...)
x |
an object of class "gTrack" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
Methods for class "KTrack"
## S3 method for class 'KTrack' print(x,...)
## S3 method for class 'KTrack' print(x,...)
x |
an object of class "KTrack" |
... |
ignored |
to print an object of class "KTrack".
Mohammad Mehdi Moradi <[email protected]>
method to print an object of class "ppplist"
## S3 method for class 'ppplist' print(x,...)
## S3 method for class 'ppplist' print(x,...)
x |
an object of class "ppplist" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
method to print an object of class "Track"
## S3 method for class 'Track' print(x,...)
## S3 method for class 'Track' print(x,...)
x |
an object of class "Track" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
method to print an object of class "Tracks"
## S3 method for class 'Tracks' print(x,...)
## S3 method for class 'Tracks' print(x,...)
x |
an object of class "Tracks" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
method to print an object of class "TracksCollection"
## S3 method for class 'TracksCollection' print(x, ...)
## S3 method for class 'TracksCollection' print(x, ...)
x |
an object of class "TracksCollection" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
Print objetcs of class "Trrow"
## S3 method for class 'Trrow' print(x,...)
## S3 method for class 'Trrow' print(x,...)
x |
an object of class "Trrow" |
... |
ignored |
Mohammad Mehdi Moradi <[email protected]>
as.Track.arrow
Retrieves the range of a "Track" object
## S3 method for class 'Track' range(X,...)
## S3 method for class 'Track' range(X,...)
X |
an object of class "Track" |
... |
passed to arguments of range |
Mohammad Mehdi Moradi <[email protected]>
rTrack, rTracks, rTracksCollection, range
x <- rTrack() range(x)
x <- rTrack() range(x)
Function reTrack accepts X as an object of class "Track". Output is a reconstructed Track (again an object of class Track), based on a regular "timestamp". It only returns the interpolated points.
reTrack(X,at=c("track","dfrm"),timestamp=timestamp,tsq=NULL)
reTrack(X,at=c("track","dfrm"),timestamp=timestamp,tsq=NULL)
X |
an object of class Track |
at |
to set the type of output as either an object of class "Track" or data.frame |
timestamp |
timestamp which Track be reconstructed based on |
tsq |
a time sequence to reconstruct Track X based on it. This is optional. If this is not given, the function creates the time sequance based on timestamp. |
Sometimes tracks data are not collected according to a regular timestamp. In order to compare different tracks which share some time intervals, we might need to be aware of the locations in a regular timestamp. Function reTrack unables us to reconstruct an object of class "Track" based on a regular timestamp. Time sequance can be given by user, if not reTrack creates a regulare time sequance based on the given timestamp.
Either an object of class "Track" or a data.frame
Mohammad Mehdi Moradi <[email protected]>
rTrack, as.Track, as.POSIXct, compare
library(sp) library(spacetime) # t0 = as.POSIXct(as.Date("2013-09-30",tz="CET")) t0 = as.POSIXct("2013-09-30 02:00:00", tz = "Europe/Berlin") # person A, track 1: x = c(7,6,5,5,4,3,3) y = c(7,7,6,5,5,6,7) n = length(x) set.seed(131) t = t0 + cumsum(runif(n) * 60) crs = CRS("+proj=longlat +datum=WGS84") # longlat stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A1 = Track(stidf) reTrack(A1,timestamp = "1 sec")
library(sp) library(spacetime) # t0 = as.POSIXct(as.Date("2013-09-30",tz="CET")) t0 = as.POSIXct("2013-09-30 02:00:00", tz = "Europe/Berlin") # person A, track 1: x = c(7,6,5,5,4,3,3) y = c(7,7,6,5,5,6,7) n = length(x) set.seed(131) t = t0 + cumsum(runif(n) * 60) crs = CRS("+proj=longlat +datum=WGS84") # longlat stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A1 = Track(stidf) reTrack(A1,timestamp = "1 sec")
Track
, Tracks
or TracksCollection
objectsGenerate random Track
, Tracks
or TracksCollection
objects
rTrack(n = 100, origin = c(0,0), start = as.POSIXct("1970-01-01"), ar = .8, step = 60, sd0 = 1, bbox = bbox, transform = FALSE, nrandom = FALSE, ...) rTracks(m = 20, start = as.POSIXct("1970-01-01"), delta = 7200, sd1 = 0, origin = c(0,0), ...) rTracksCollection(p = 10, sd2 = 0, ...)
rTrack(n = 100, origin = c(0,0), start = as.POSIXct("1970-01-01"), ar = .8, step = 60, sd0 = 1, bbox = bbox, transform = FALSE, nrandom = FALSE, ...) rTracks(m = 20, start = as.POSIXct("1970-01-01"), delta = 7200, sd1 = 0, origin = c(0,0), ...) rTracksCollection(p = 10, sd2 = 0, ...)
n |
number of points per Track |
origin |
numeric, length two, indicating the origin of the Track |
start |
POSIXct, indicating the start time of the Track |
ar |
numeric vector, indicating the amound of correlation in the Track |
step |
numeric; time step(s) in seconds between Track fixes |
sd0 |
standard deviation of the random steps in a Track |
sd1 |
standard deviation of the consecutive Track origin values (using rnorm) |
sd2 |
standard deviation of the consecutive Tracks origin values (using rnorm) |
bbox |
bbox object FIXME:fill in |
transform |
logical; FIXME:fill in |
nrandom |
logical; if |
... |
rTrack: arguments passed on to arima.sim, rTracks: arguments passed on to rTrack; rTracksCollection: arguments passed on to rTracks |
m |
number of Track objects to simulate |
delta |
time difference between consecutive Track start times |
p |
number of IDs with Tracks to generate |
ar
is passed on to arima.sim as ar
element, and may contain multiple AR coefficients. The generated
track is a cumsum over the simulated AR values, for each dimension.
In case it has length 1 and value 0, random walk is created using rnorm. If bbox is given, the generated track will be transformed to bbox. If transform is TRUE and no bbox is given, it transforms the track to a unit box. If nrandom is TRUE, it generates a random number using rpois with parameter n as the number of locations per track.
An object of class Track
, Tracks
or TracksCollection
.
Edzer Pebesma <[email protected]>, Mohammad Mehdi Moradi <[email protected]>
x = rTrack() dim(x) plot(x) # x = rTracks(sd1 = 120) # dim(x) # plot(as(x, "SpatialLines"), col = 1:dim(x)[1], axes=TRUE) # x = rTracksCollection() # star # dim(x) # plot(x) x = rTracksCollection(sd2 = 200,p=4,m=10) plot(x, col=1:dim(x)[1])
x = rTrack() dim(x) plot(x) # x = rTracks(sd1 = 120) # dim(x) # plot(as(x, "SpatialLines"), col = 1:dim(x)[1], axes=TRUE) # x = rTracksCollection() # star # dim(x) # plot(x) x = rTracksCollection(sd2 = 200,p=4,m=10) plot(x, col=1:dim(x)[1])
obtain ranges of space and time coordinates
stbox(obj)
stbox(obj)
obj |
object of a class deriving from |
stbox
returns a data.frame
, with three columns
representing x-, y- and time-coordinates, and two rows containing min
and max values. bbox
gives a matrix with coordinate min/max values,
compatible to bbox
signature(x = "Tracks")
: obtain st range from object
signature(x = "TracksCollection")
: obtain st range from object
Draw a space-time cube for a Track, TRacks, TracksCollection, difftrack or STI(DF) class.
## S4 method for signature 'Track' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "l", aspect, xlim = stbox(x)[[1]] + c(-0.1,0.1) * diff(stbox(x)[[1]]), ylim = stbox(x)[[2]] + c(-0.1,0.1) * diff(stbox(x)[[2]]), zlim = stbox(x)$time, showMap = FALSE, mapType = "osm", mapZoom = NULL, ..., y, z) ## S4 method for signature 'Tracks' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "l", aspect, xlim, ylim, zlim, showMap = FALSE, mapType = "osm", normalizeBy = "week", mapZoom = NULL, ..., y, z, col) ## S4 method for signature 'TracksCollection' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "l", aspect, xlim, ylim, zlim, showMap = FALSE, mapType = "osm", normalizeBy = "week", mapZoom = NULL, ..., y, z, col) ## S4 method for signature 'difftrack' stcube(x, showMap = FALSE, mapType = "osm", normalizeBy = "week", ..., y, z) ## S4 method for signature 'STI' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "p", aspect, xlim = stbox(x)[[1]] + c(-0.1,0.1) * diff(stbox(x)[[1]]), ylim = stbox(x)[[2]] + c(-0.1,0.1) * diff(stbox(x)[[2]]), zlim = stbox(x)$time, showMap = FALSE, mapType = "osm", mapZoom = NULL, ..., y, z) ## S4 method for signature 'STIDF' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "p", aspect, xlim = stbox(x)[[1]] + c(-0.1,0.1) * diff(stbox(x)[[1]]), ylim = stbox(x)[[2]] + c(-0.1,0.1) * diff(stbox(x)[[2]]), zlim = stbox(x)$time, showMap = FALSE, mapType = "osm", mapZoom = NULL, col, ..., y, z)
## S4 method for signature 'Track' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "l", aspect, xlim = stbox(x)[[1]] + c(-0.1,0.1) * diff(stbox(x)[[1]]), ylim = stbox(x)[[2]] + c(-0.1,0.1) * diff(stbox(x)[[2]]), zlim = stbox(x)$time, showMap = FALSE, mapType = "osm", mapZoom = NULL, ..., y, z) ## S4 method for signature 'Tracks' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "l", aspect, xlim, ylim, zlim, showMap = FALSE, mapType = "osm", normalizeBy = "week", mapZoom = NULL, ..., y, z, col) ## S4 method for signature 'TracksCollection' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "l", aspect, xlim, ylim, zlim, showMap = FALSE, mapType = "osm", normalizeBy = "week", mapZoom = NULL, ..., y, z, col) ## S4 method for signature 'difftrack' stcube(x, showMap = FALSE, mapType = "osm", normalizeBy = "week", ..., y, z) ## S4 method for signature 'STI' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "p", aspect, xlim = stbox(x)[[1]] + c(-0.1,0.1) * diff(stbox(x)[[1]]), ylim = stbox(x)[[2]] + c(-0.1,0.1) * diff(stbox(x)[[2]]), zlim = stbox(x)$time, showMap = FALSE, mapType = "osm", mapZoom = NULL, ..., y, z) ## S4 method for signature 'STIDF' stcube(x, xlab = "x", ylab = "y", zlab = "t", type = "p", aspect, xlim = stbox(x)[[1]] + c(-0.1,0.1) * diff(stbox(x)[[1]]), ylim = stbox(x)[[2]] + c(-0.1,0.1) * diff(stbox(x)[[2]]), zlim = stbox(x)$time, showMap = FALSE, mapType = "osm", mapZoom = NULL, col, ..., y, z)
x |
An object of class |
xlab , ylab , zlab , type , aspect , xlim , ylim , zlim
|
Arguments passed to plot3d() of package |
showMap |
Flag if a basemap is to be shown on the xy plane; for this to function, you may need to load library |
mapType |
The tile server from which to get the map. Passed as |
normalizeBy |
An abstract time period (either |
mapZoom |
Set a zoom level for the map used as background. Null will use the osm package default strategie. |
y , z , col
|
Ignored, but included in the method signature for implementation reasons. |
... |
Additional arguments passed to plot3d() of package |
A space-time cube.
## Not run: demo(stcube)
## Not run: demo(stcube)
storm trajectories, 2009-2012, from http://weather.unisys.com/hurricane/atlantic/
data(storms)
data(storms)
data(storms) dim(storms) plot(storms) x = approxTracksCollection(storms, by = "30 min", FUN = spline) plot(x, col = 'red', add = TRUE) ## Not run: demo(storms) # regenerates these data from their source ## End(Not run)
data(storms) dim(storms) plot(storms) x = approxTracksCollection(storms, by = "30 min", FUN = spline) plot(x, col = 'red', add = TRUE) ## Not run: demo(storms) # regenerates these data from their source ## End(Not run)
Classes for representing sets of trajectory data, with attributes, for different IDs (persons, objects, etc)
Track(track, df = fn(track), fn = TrackStats) Tracks(tracks, tracksData = data.frame(row.names=names(tracks)), fn = TrackSummary) TracksCollection(tracksCollection, tracksCollectionData, fn = TracksSummary) TrackStats(track) TrackSummary(track) TracksSummary(tracksCollection) ## S4 method for signature 'Track' x[i, j, ..., drop = TRUE] ## S4 method for signature 'TracksCollection' x[i, j, ..., drop = TRUE] ## S4 method for signature 'Track,data.frame' coerce(from, to) ## S4 method for signature 'Tracks,data.frame' coerce(from, to) ## S4 method for signature 'TracksCollection,data.frame' coerce(from, to)
Track(track, df = fn(track), fn = TrackStats) Tracks(tracks, tracksData = data.frame(row.names=names(tracks)), fn = TrackSummary) TracksCollection(tracksCollection, tracksCollectionData, fn = TracksSummary) TrackStats(track) TrackSummary(track) TracksSummary(tracksCollection) ## S4 method for signature 'Track' x[i, j, ..., drop = TRUE] ## S4 method for signature 'TracksCollection' x[i, j, ..., drop = TRUE] ## S4 method for signature 'Track,data.frame' coerce(from, to) ## S4 method for signature 'Tracks,data.frame' coerce(from, to) ## S4 method for signature 'TracksCollection,data.frame' coerce(from, to)
track |
object of class STIDF-class, representing a single trip |
df |
optional |
tracks |
named list with |
tracksData |
|
tracksCollection |
list, with |
tracksCollectionData |
data.frame, with summary data on
|
fn |
function; |
x |
object of class |
i |
selection of spatial entities |
j |
selection of temporal entities (see syntax in package xts) |
... |
selection of attribute(s) |
drop |
logical |
from |
from |
to |
target class |
Functions Track
, Tracks
and
TracksCollection
are constructor functions that take the
slots as arguments, check object validity, and compute summary
statistics on the track and tracks sets.
TrackStats
returns a data.frame
with for each track
segment the distance, duration, speed, and direction. In case data are
geographical coordinates (long/lat), distance is in m, and direction
is initial bearing.
TrackSummary
reports for each track xmin, xmax, ymin, ymax,
tmin, tmax, (number of points) n, (total) distance, and medspeed
(median speed).
TracksSummary
reports for each Tracks of a TracksCollection
(number of tracks) n, xmin, xmax, ymin, ymax, tmin, tmin, tmax.
Objects of class Track
extend STIDF-class
and contain single trips or tracks,
objects of class Tracks
contain multiple Track
objects
for a single ID (person, object or tracking device), objects of class
TracksCollection
contain multiple Tracks
objects for
different IDs.
sp
:spatial locations of the track points, with length n
time
:time stamps of the track points
endTime
:end time stamps of the track points
data
:data.frame
with n rows, containing
attributes of the track points
connections
:data.frame
, with n-1 rows, containing
attributes between the track points such as distance and speed
tracks
:list
with Track
objects, of length m
tracksData
:data.frame
with m rows, containing
summary data for each Track
object
tracksCollection
:list
Tracks
objects, of
length p
tracksCollectionData
:data.frame
with p rows,
containing summary data for each Tracks
object
signature(obj = "Track")
: retrieves the attribute element
signature(obj = "Tracks")
: retrieves the attribute element
signature(obj = "TracksCollection")
: retrieves the attribute element
signature(obj = "Track")
: sets or replaces the attribute element
signature(obj = "Tracks")
: sets or replaces the attribute element
signature(obj = "TracksCollection")
: sets or replaces the attribute element
signature(obj = "Track")
: retrieves the attribute element
signature(obj = "Tracks")
: retrieves the attribute element
signature(obj = "TracksCollection")
: retrieves the attribute element
signature(obj = "Track")
: sets or replaces the attribute element
signature(obj = "Tracks")
: sets or replaces the attribute element
signature(obj = "TracksCollection")
: sets or replaces the attribute element
signature(from = Track, to = data.frame)
coerce to data.frame
signature(from = Tracks, to = data.frame)
coerce to data.frame
signature(form = TracksCollection, to = data.frame)
coerce to data.frame
signature(x = "TracksCollection", y = "missing")
:
plots sets of sets of tracks
signature(obj = "TracksCollection")
:
plots sets of sets of tracks
segments
is a data.frame
form in which track
segments instead of track points form a record, with x0
,
y0
, x1
and y1
the start and end coordinates
Edzer Pebesma, [email protected]
http://www.jstatsoft.org/v51/i07/
library(sp) library(spacetime) # t0 = as.POSIXct(as.Date("2013-09-30",tz="CET")) t0 = as.POSIXct("2013-09-30 02:00:00", tz = "Europe/Berlin") # person A, track 1: x = c(7,6,5,5,4,3,3) y = c(7,7,6,5,5,6,7) n = length(x) set.seed(131) t = t0 + cumsum(runif(n) * 60) crs = CRS("+proj=longlat +datum=WGS84") # longlat stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A1 = Track(stidf) # person A, track 2: x = c(7,6,6,7,7) y = c(6,5,4,4,3) n = length(x) t = max(t) + cumsum(runif(n) * 60) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A2 = Track(stidf) # Tracks for person A: A = Tracks(list(A1=A1,A2=A2)) # person B, track 1: x = c(2,2,1,1,2,3) y = c(5,4,3,2,2,3) n = length(x) t = max(t) + cumsum(runif(n) * 60) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) B1 = Track(stidf) # person B, track 2: x = c(3,3,4,3,3,4) y = c(5,4,3,2,1,1) n = length(x) t = max(t) + cumsum(runif(n) * 60) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) B2 = Track(stidf) # Tracks for person A: B = Tracks(list(B1=B1,B2=B2)) Tr = TracksCollection(list(A=A,B=B)) stplot(Tr, scales = list(draw=TRUE)) stplot(Tr, attr = "direction", arrows=TRUE, lwd = 3, by = "direction") stplot(Tr, attr = "direction", arrows=TRUE, lwd = 3, by = "IDs") plot(Tr, col=2, axes=TRUE) dim(Tr) dim(Tr[2]) dim(Tr[2][1]) u = stack(Tr) # four IDs dim(u) dim(unstack(u, c(1,1,2,2))) # regroups to original dim(unstack(u, c(1,1,2,3))) # regroups to three IDs dim(unstack(u, c(1,2,2,1))) # regroups differently as(Tr, "data.frame")[1:10,] # tracks separated by NA rows as(Tr, "segments")[1:10,] # track segments as records Tr[["distance"]] = Tr[["distance"]] * 1000 Tr$distance = Tr$distance / 1000 Tr$distance # work with custum TrackStats function: MyStats = function(track) { df = apply(coordinates(track@sp), 2, diff) # requires sp data.frame(distance = apply(df, 1, function(x) sqrt(sum(x^2)))) } crs = CRS(as.character(NA)) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) B2 = Track(stidf) # no longer longlat; B3 = Track(stidf, fn = MyStats) all.equal(B3$distance, B2$distance) # approxTrack: opar = par() par(mfrow = c(1, 2)) plot(B2, ylim = c(.5, 6)) plot(B2, pch = 16, add = TRUE) title("irregular time steps") i = index(B2) B3 = approxTrack(B2, seq(min(i), max(i), length.out = 50)) plot(B3, col = 'red', type = 'p', add = TRUE) B4 = approxTrack(B2, seq(min(i), max(i), length.out = 50), FUN = spline) plot(B4, col = 'blue', type = 'b', add = TRUE) # regular time steps: t = max(t) + (1:n) * 60 # regular B2 = Track(STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n)))) plot(B2, ylim = c(.5, 6)) plot(B2, pch = 16, add = TRUE) title("constant time steps") i = index(B2) B3 = approxTrack(B2) plot(B3, type = 'p', col = 'red', add = TRUE) B4 = approxTrack(B2, FUN = spline) plot(B4, type = 'p', col = 'blue', add = TRUE) # par(opar) # good to do, but would generate warnings smth = function(x,y,xout,...) predict(smooth.spline(as.numeric(x), y), as.numeric(xout)) data(storms) plot(storms, type = 'p') storms.smooth = approxTracksCollection(storms, FUN = smth, n = 200) plot(storms.smooth, add = TRUE, col = 'red')
library(sp) library(spacetime) # t0 = as.POSIXct(as.Date("2013-09-30",tz="CET")) t0 = as.POSIXct("2013-09-30 02:00:00", tz = "Europe/Berlin") # person A, track 1: x = c(7,6,5,5,4,3,3) y = c(7,7,6,5,5,6,7) n = length(x) set.seed(131) t = t0 + cumsum(runif(n) * 60) crs = CRS("+proj=longlat +datum=WGS84") # longlat stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A1 = Track(stidf) # person A, track 2: x = c(7,6,6,7,7) y = c(6,5,4,4,3) n = length(x) t = max(t) + cumsum(runif(n) * 60) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A2 = Track(stidf) # Tracks for person A: A = Tracks(list(A1=A1,A2=A2)) # person B, track 1: x = c(2,2,1,1,2,3) y = c(5,4,3,2,2,3) n = length(x) t = max(t) + cumsum(runif(n) * 60) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) B1 = Track(stidf) # person B, track 2: x = c(3,3,4,3,3,4) y = c(5,4,3,2,1,1) n = length(x) t = max(t) + cumsum(runif(n) * 60) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) B2 = Track(stidf) # Tracks for person A: B = Tracks(list(B1=B1,B2=B2)) Tr = TracksCollection(list(A=A,B=B)) stplot(Tr, scales = list(draw=TRUE)) stplot(Tr, attr = "direction", arrows=TRUE, lwd = 3, by = "direction") stplot(Tr, attr = "direction", arrows=TRUE, lwd = 3, by = "IDs") plot(Tr, col=2, axes=TRUE) dim(Tr) dim(Tr[2]) dim(Tr[2][1]) u = stack(Tr) # four IDs dim(u) dim(unstack(u, c(1,1,2,2))) # regroups to original dim(unstack(u, c(1,1,2,3))) # regroups to three IDs dim(unstack(u, c(1,2,2,1))) # regroups differently as(Tr, "data.frame")[1:10,] # tracks separated by NA rows as(Tr, "segments")[1:10,] # track segments as records Tr[["distance"]] = Tr[["distance"]] * 1000 Tr$distance = Tr$distance / 1000 Tr$distance # work with custum TrackStats function: MyStats = function(track) { df = apply(coordinates(track@sp), 2, diff) # requires sp data.frame(distance = apply(df, 1, function(x) sqrt(sum(x^2)))) } crs = CRS(as.character(NA)) stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) B2 = Track(stidf) # no longer longlat; B3 = Track(stidf, fn = MyStats) all.equal(B3$distance, B2$distance) # approxTrack: opar = par() par(mfrow = c(1, 2)) plot(B2, ylim = c(.5, 6)) plot(B2, pch = 16, add = TRUE) title("irregular time steps") i = index(B2) B3 = approxTrack(B2, seq(min(i), max(i), length.out = 50)) plot(B3, col = 'red', type = 'p', add = TRUE) B4 = approxTrack(B2, seq(min(i), max(i), length.out = 50), FUN = spline) plot(B4, col = 'blue', type = 'b', add = TRUE) # regular time steps: t = max(t) + (1:n) * 60 # regular B2 = Track(STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n)))) plot(B2, ylim = c(.5, 6)) plot(B2, pch = 16, add = TRUE) title("constant time steps") i = index(B2) B3 = approxTrack(B2) plot(B3, type = 'p', col = 'red', add = TRUE) B4 = approxTrack(B2, FUN = spline) plot(B4, type = 'p', col = 'blue', add = TRUE) # par(opar) # good to do, but would generate warnings smth = function(x,y,xout,...) predict(smooth.spline(as.numeric(x), y), as.numeric(xout)) data(storms) plot(storms, type = 'p') storms.smooth = approxTracksCollection(storms, FUN = smth, n = 200) plot(storms.smooth, add = TRUE, col = 'red')
Movement smoothing of trajectory pattern
Track.idw(X,timestamp,epsilon=epsilon,...)
Track.idw(X,timestamp,epsilon=epsilon,...)
X |
a list of objects of class "Track" |
timestamp |
based on secs,mins, ... |
epsilon |
(optional) movements with length less than epsilon are not considered in the calculation |
... |
passed to arguments of fucntion idw in spatstat |
Performs spatial smoothing to the movements of a list of tracks.
an image of class "im".
Mohammad Mehdi Moradi <[email protected]>
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Track.idw(X,timestamp="180 secs") }
if (require(spatstat.geom)) { X <- list() for(i in 1:10){ m <- matrix(c(0,10,0,10),nrow=2,byrow = TRUE) X[[i]] <- rTrack(bbox = m,transform = TRUE) } Track.idw(X,timestamp="180 secs") }
tsqtracks returns a sequance of time based on a list of tracks (or a single object of class "Track"") and an argument timestamp.
tsqTracks(X,timestamp)
tsqTracks(X,timestamp)
X |
either an object of class "Track"" or a list of some objects of class "Track" |
timestamp |
a timestamp to create the time sequence based on it |
This creates a sequence of time based on a track or a list of tracks.
An object of class "POSIXct" or "POSIXt".
Mohammad Mehdi Moradi <[email protected]>
rTrack
library(sp) library(spacetime) # t0 = as.POSIXct(as.Date("2013-09-30",tz="CET")) t0 = as.POSIXct("2013-09-30 02:00:00", tz = "Europe/Berlin") # person A, track 1: x = c(7,6,5,5,4,3,3) y = c(7,7,6,5,5,6,7) n = length(x) set.seed(131) t = t0 + cumsum(runif(n) * 60) crs = CRS("+proj=longlat +datum=WGS84") # longlat stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A1 = Track(stidf) tsqTracks(A1,timestamp = "1 sec")
library(sp) library(spacetime) # t0 = as.POSIXct(as.Date("2013-09-30",tz="CET")) t0 = as.POSIXct("2013-09-30 02:00:00", tz = "Europe/Berlin") # person A, track 1: x = c(7,6,5,5,4,3,3) y = c(7,7,6,5,5,6,7) n = length(x) set.seed(131) t = t0 + cumsum(runif(n) * 60) crs = CRS("+proj=longlat +datum=WGS84") # longlat stidf = STIDF(SpatialPoints(cbind(x,y),crs), t, data.frame(co2 = rnorm(n))) A1 = Track(stidf) tsqTracks(A1,timestamp = "1 sec")
Removing duplicated points in a track
## S3 method for class 'Track' unique(x,...)
## S3 method for class 'Track' unique(x,...)
x |
an object of class "Track" |
... |
passed to arguments of unique |
This function removes duplicated points in an object of class "Track".
An object of class Track with no duplicated point.
Mohammad Mehdi Moradi <[email protected]>
rTrack, rTracks, rTracksCollection, unique
x <- rTrack() unique(x)
x <- rTrack() unique(x)