traj_dist 笔记:测量轨迹距离

python 笔记 :trajectory_distance包(如何可以正确使用)【debug篇】-CSDN博客

经过前面的debug后,在setup.py对应的位置,写代码(直接在别处import traj_dist我还是出问题)

1 新建轨迹

import numpy as np

# Three 2-D Trajectory
traj_A = np.array([[-122.39534, 37.77678],[-122.3992 , 37.77631],[-122.40235, 37.77594],[-122.40553, 37.77848],
                   [-122.40801, 37.78043],[-122.40837, 37.78066],[-122.41103, 37.78463],[-122.41207, 37.78954],
                   [-122.41252, 37.79232],[-122.41316, 37.7951 ],[-122.41392, 37.7989 ],[-122.41435, 37.80129],
                   [-122.41434, 37.80129]])
traj_B = np.array([[-122.39472, 37.77672],[-122.3946 , 37.77679],[-122.39314, 37.77846],[-122.39566, 37.78113],
                   [-122.39978, 37.78438],[-122.40301, 37.78708],[-122.4048 , 37.78666],[-122.40584, 37.78564],
                   [-122.40826, 37.78385],[-122.41061, 37.78321],[-122.41252, 37.78299]])
traj_C = np.array([[-122.39542, 37.77665],[-122.3988 , 37.77417],[-122.41042, 37.76944],[-122.41459, 37.77016],
                   [-122.41462, 37.77013]])
traj_list = [traj_A, traj_B, traj_C]

2 导入包

import traj_dist.distance as tdist

3 单对轨迹的距离

tdist.sspd(traj_A,traj_B)
#0.0058480061454797665

4 pdist 和cdist

tdist.pdist(traj_list,metric="sspd")
'''
Computing euclidean distance sspd with implementation cython for 3 trajectories
array([0.00584801, 0.01141902, 0.00888597])
'''
tdist.cdist(traj_list,traj_list,metric="sspd")
'''
Computing euclidean distance sspd with implementation cython for 3 and 3 trajectories
array([[0.        , 0.00584801, 0.01141902],
       [0.00584801, 0.        , 0.00888597],
       [0.01141902, 0.00888597, 0.        ]])
'''

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UQI-LIUWJ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值