Learn R Programming

trajectories (version 0.1-4)

dists: Calculate distances between two Tracks objects

Description

Calculates a distance matrix with distances for each pair of tracks.

Usage

## S3 method for class 'Tracks':
dists(tr1, tr2, f, ...)

Arguments

tr1
An object of class Tracks.
tr2
An object of class Tracks.
f
A function to calculate distances. Default is mean.
...
Additional parameters passed to f.

Value

  • A matrix with distances between each pair of tracks or NA if they don't overlap in time.

Details

f can be any function applicable to a numerical vector or frechetDist.

Examples

Run this code
## 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
dists(tracks1, tracks2)
dists(tracks1, tracks2, sum)
dists(tracks1, tracks2, frechetDist)

Run the code above in your browser using DataLab