=====================
trajectory_distance is a Python module for computing distances between 2D-trajectory objects. It is implemented in Cython.
9 distances between trajectories are available in the trajectory_distance package.
All distances but Discret Frechet and Discret Frechet are are available with Euclidean or Spherical option :
Grid representation are used to compute the OWD distance.
Python implementation is also available in this depository but are not used within traj_dist.distance
module.
trajectory_distance is tested to work under Python 3.6 and the following dependencies:
This package can be build using distutils
.
Move to the package directory and run :
python setup.py install
to build Cython files. Then run:
pip install .
to install the package into your environment.
You only need to import the distance module.
import traj_dist.distance as tdist
All distances are in this module. There are also two extra functions 'cdist', and 'pdist' to compute pairwise distances between all trajectories in a list or two lists.
Trajectory should be represented as nx2 numpy array.
See traj_dist/example.py
file for a small working exemple.
Some distance requires extra-parameters. See the help function for more information about how to use each distance.
The time required to compute pairwise distance between 100 trajectories (4950 distances), composed from 3 to 20 points (data/benchmark.csv
) :
Euclidan | Spherical | |
---|---|---|
discret frechet | 0.0659620761871 | -1.0 |
dtw | 0.0781569480896 | 0.114996194839 |
edr | 0.0695221424103 | 0.106939792633 |
erp | 0.171737909317 | 0.319380998611 |
frechet | 29.1885719299 | -1.0 |
hausdorff | 0.310199975967 | 0.780081987381 |
lcss | 0.0711951255798 | 0.111418008804 |
sowd grid, precision 5 | 0.164781093597 | 0.159924983978 |
sowd grid, precision 6 | 0.973792076111 | 0.954225063324 |
sowd grid, precision 7 | 7.62574410439 | 7.78553795815 |
sspd | 0.314118862152 | 0.807314872742 |
See traj_dist/benchmark.py
to generate this benchmark on your computer.