GPS 数据时间到距离基础转换
我正在开发一个记录 GPS 轨迹随时间变化的应用程序。
跟踪完成后,我需要将基于时间的数据转换为基于距离的数据,也就是说,原始跟踪每秒有一个经度/纬度记录,我需要将其转换为每秒有一个经度/纬度记录20米。
平滑原始数据似乎是一个很好理解的问题,我想我需要诸如平滑算法之类的东西,但我正在努力思考如何从基于时间的数据集转换为基于距离的数据放。
I am developing an application that logs a GPS trace over time.
After the trace is complete, I need to convert the time based data to distance based data, that is to say, where the original trace had a lon/lat record every second, I need to convert that into having a lon/lat record every 20 meters.
Smoothing the original data seems to be a well understood problem and I suppose I need something like a smoothing algorithm, but I'm struggling to think how to convert from a time based data set to a distance based data set.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个很好的问题,它如此有趣的原因是数据点应该假设是随机的。这意味着您不能期望一个从开始到结束的数据图代表一个表现良好的多项式(如正弦波或余弦波)。因此,您必须以较小的增量进行工作,以便 x 轴上的值(可以这么说)不会振荡,这意味着 Xn 不能小于 Xn-1。下一个考虑因素是数据点重叠或接近重叠的情况。想象一下,我正在记录我的 GPS 坐标,我们停下来聊天或休息,接下来的五分钟我在 25 英尺的圆圈内随机行走。那么问题是如何忽略这种类型的“数据噪音”?
为了简单起见,我们考虑线性计算,其中两点之间没有近似值;这是一条直线。这对于您的计算来说可能绰绰有余。现在考虑到上面关于随机数据点的评论,您将希望按顺序从起点到终点遍历数据。当超过最后一个数据点或超过生成坐标的总距离(如子集)时,会发生顺序终止。假设您的绘图精度为 X。这就是您的 20 米。当你遍历时,会出现三个条件:
精确。因此保存起点加上精度X。这
也将成为你新的起点。
因此保存起始点加上精度X(或保存结束点
观点)。这也将成为你新的起点。
因此精度调整为精度减去终点。结束
点将成为你新的起点。
这是可能帮助您入门的伪代码。注意,点 y 减去点 x = 之间的距离。并且,点 x 加值 = 点 x 和点 y 之间的直线上距离值的新点。
之前我提到过“数据噪声”。您可以将“if”和“else if”包装在另一个“if”中,这决定了是否删除此因素。最简单的方法是忽略未移动给定距离的数据点。请记住,这个神奇的数字必须足够小,以便被忽略的顺序记录的数据点的总和不会变得很大且有价值。因此,对被忽略的数据点进行限制可能是有好处的。
话虽如此,有很多方法可以准确地执行此操作。将这个主题提升到一个新水平的一个建议是插值。对于 .NET,在 http://www.mathdotnet.com 处有一个开源库。您可以使用他们的包含插值的 Numberics 库 http://numerics.mathdotnet.com/interpolation/。如果您选择这样的路线,您的下一个主要障碍将是决定适当的插值技术。如果您不是数学大师,这里有一些帮助您入门的信息 http://en.wikipedia .org/wiki/Interpolation。坦率地说,如果您考虑 Xn 的想法不小于,那么使用两个相邻点的多项式插值对于您的近似来说就足够了。 Xn-1 否则你的近似值将会倾斜。
最后要注意的是,这些计算是二维的,并且考虑了高度(方位角)或地球的曲率。以下是这方面的一些附加信息:计算之间的距离两个经纬度点? (半正矢公式)。
尽管如此,希望这能为您指明正确的方向。毫无疑问,这不是一个小问题,因此在保持准确的同时保持数据点范围尽可能小将对您有利。
另一种考虑可能是使用实际数据点进行近似,使用精度来忽略过多的数据。因此,您本质上并不是保存两个坐标列表。
干杯,
杰夫
This is an excellent question and what makes it so interesting is the data points should be assumed random. Which means you cannot expect a beginning to end data graph that represents a well behaved polynomial (like SINE or COS wave). So you will have to work in small increments such that values on your x-axis (so to speak) do not oscillate meaning Xn cannot be less than Xn-1. The next consideration would be the case of overlap or near overlap of data points. Imagine I’m recording my GPS coordinates and we have stopped to chat or rest and I walk randomly within a twenty five foot circle for the next five minutes. So the question would be how to ignore this type of “data noise”?
For simplicity let’s consider linear calculations where there is no approximation between two points; it’s a straight line. This will probably be more than sufficient for your calculations. Now given the comment above regarding random data points, you will want to traverse your data from your start point to the end point sequentially. Sequential termination occurs when you exceed the last data point or you have exceeded the overall distance to produce coordinates (like a subset). Let’s assume your plot precision is X. This would be your 20 meters. As you traverse there will be three conditions:
precision. Therefore save the start point plus the precision X. This
will also become your new start point.
Therefore save the start point plus the precision X (or save end
point). This will also become your new start point.
Therefore precision is adjusted to precision minus end point. The end
point will become your new start point.
Here is pseudo-code that might help get you started. Note, point y minus point x = distance between. And, point x plus value = new point on line between poing x and point y at distance value.
Previously I mentioned "data noise". You can wrap the "if" and "else if's" in another "if" which detemines scrubs this factor. The easiest way is to ignore a data point if it has not moved a given distance. Keep in mind this magic number must be small enough such that sequentially recorded data points which are ignored don't sum to something large and valuable. So putting a limit on ignored data points might be a benefit.
With all this said, there are many ways to accurately perform this operation. One suggestion to take this subject to the next level is Interpolation. For .NET there is a open source library at http://www.mathdotnet.com. You can use their Numberics library which contains Interpolation at http://numerics.mathdotnet.com/interpolation/. If you choose such a route your next major hurdle will be deciding the appropriate Interpolation technique. If you are not a math guru here is a bit of information to get you started http://en.wikipedia.org/wiki/Interpolation. Frankly, Polynomial Interpolation using two adjacent points would be more than sufficient for your approximations provided you consider the idea of Xn is not < Xn-1 otherwise your approximation will be skewed.
The last item to note, these calculations are two-dimensional and do consider altitude (Azimuth) or the curvature of the earth. Here is some additional information in that regard: Calculate distance between two latitude-longitude points? (Haversine formula).
Never the less, hopefully this will point you in the correct direction. With no doubt this is not a trivial problem therefore keeping the data point range as small as possible while still being accurate will be to your benefit.
One other consideration might be to approximate using actual data points using the precision to disregard excessive data. Therefore you are not essentially saving two lists of coordinates.
Cheers,
Jeff