我有一个数据集,从我的谷歌帐户的GPS日志,我想从CSV删除离群点,显然是不打算在那里。
例如,GPS显示你在1,1 > 1,2 > 9,6 > 1,2 > 1,1
,所以位置上的一个主要变化,几秒钟后回到了几秒前的地方。
我已经尝试过用GPS的速度进行过滤,但这可以移除在飞行中形成的GPS点。当全球定位系统正常时,这也不起作用,然后稍晚更新,然后上升到500公里之外,停留在那里10分钟,然后自我修正,因为移动速度会低到足以通过“速度测试”。
如何在约430 K行的数据集中检测到这些数据?就像在一架非常罕见的GPS更新的飞机上旅行一样,我们也需要处理这些问题。
发布于 2021-04-08 17:25:33
我已经决定了一个混合解决方案。
。
代码
from geopy import distance
d1 = distance.distance(coords_1, coords_2)
d1 = float(str(d1)[:-3])*1000 # Convert to meters
FMT = "%Y-%m-%d %H:%M:%S" #Formatting so it matches CSV
Time = (datetime.strptime(cur_line["Time"], FMT) - datetime.strptime(pre_line["Time"],
FMT)).total_seconds()
Velocity = d1 / Time
if Velocity < 800: # Set this to your needs
# DO Stuff
余弦的
代码:
from geopy import distance
from trianglesolver import solve
from math import degrees
d1 = distance.distance(coords_1, coords_2)
d2 = distance.distance(coords_2, coords_3)
d3 = distance.distance(coords_3, coords_1)
d1 = float(str(d1)[:-3])*1000
d2 = float(str(d2)[:-3])*1000
d3 = float(str(d3)[:-3])*1000
degTresh = 30.0
if d1 > 0.01 and d2 > 0.01 and d3 > 0.01: # if they are 0, there will be an error
a,b,c,A,B,C = solve(a=d1, b=d2, c=d3) # Calculate the angles from the sides
A,B,C = degrees(A), degrees(B), degrees(C) # Convert to math.degrees
if (360.0 - degTresh) < C or C < degTresh:
spike= True
else:
spike = False
这两种方法结合起来效果相当好,而且大多数情况下,当站着时,甚至会去除小的GPS尖峰。
https://stackoverflow.com/questions/65616638
复制相似问题