Trajectory_distance
As I recently helped the teacher to write a paper whose experiment needs to calculate the similarity of the two trajectories. There are very few related Chinese information in web, of which this article has given me a lot of help. The author of the article recommends a Python module — traj_dist.
1. Description
Trajectory_distance(traj_dist) is a Python module for computing distances between 2D-trajectory objects. It is implemented in Cython. The author of traj_dist packed some common methods together.
9 distances between trajectories are available in the trajectory_distance package:
1.SSPD (Symmetric Segment-Path Distance)
2.OWD (One-Way Distance)
3.Hausdorff
4.Frechet
5.Discret Frechet
6.DTW (Dynamic Time Warping)
7.LCSS (Longuest Common Subsequence)
8.ERP (Edit distance with Real Penalty)
9.EDR (Edit Distance on Real sequence)
2. How to use
The installation is simple. For details, please refer to the GitHub project.
Just import the distance module.
1 | import traj_dist.distance as tdist |
Trajectory should be represented as nx2 numpy array. So I got this:
1 | traj_a = np.array(traj_a,dtype=np.float64) |
Some distance requires extra-parameters. See the help function for more information about how to use each distance. Such as “spherical” and “euclidean”. They represent the spherical distance and European-style distance.
3. Some Points
It should be noted that there are no relevant tutorials on the Internet. If you encounter problems at running, please check the source code.
The author of this article proposes that EDR has some errors, but I didn’t find the error codes.