如何“平均”使用 C#/SQL Server 2008 空间的两个或多个地理线串

发布于 2024-10-04 15:17:59 字数 478 浏览 7 评论 0原文

假设我从对特定候鸟行为的研究中获得了一组结果。这只鸟已被贴上标签,GPS接收器记录了它在五年内每年的迁徙路径。 结果存储在一个 SQL Server 表中,该表包含每年路径的一个地理线串。

您将如何定义代表五年期间遵循的“平均”路径的线串?

请注意,每个样本线串可能包含不同数量的点。它们也不会在完全相同的点开始和结束。

到目前为止,我得到的最好方法是使用插值来确定沿每个线串的特定设定比例的点。例如,起点、四分之一的路程、每条路线的一半等。 然后计算所有路线上这些位置的平均纬度/经度,并根据这些平均点构建新的地理线串。

我查阅了一些计算几何书籍,看看是否有更好的已知算法或技术可以做到这一点,但似乎没有任何相关的内容。我不敢相信这不是其他人以前没有做过的事情......

我不需要确切的代码 - 只是对任何更好的通用方法的建议。我也不需要“超级准确”。作为旁注,我理想希望该方法也适用于两个或多个多边形。

感谢您的任何建议!

Suppose I've got a set of results from a study into the behaviour of a particular migratory bird. The bird has been tagged, and a GPS receiver records the migration path it follows each year over a five year period.
The results are stored in a SQL Server table that contains one geography linestring for each year's path.

How would you go about defining the linestring representing the "average" path followed over the five year period?

Note that each sample linestring may contain a different number of points. They also don't start and end at exactly the same points.

The best approach I've got so far is to use interpolation to determine the points at certain set proportions along each linestring. So, for example, the start point, a quarter of the way along, halfway along each route etc.
Then calculate the mean average lat/long of those positions across all routes, and construct a new geography linestring from those averaged points.

I've looked in a few computational geometry books to see if there's a better known algorithm or technique to do this, but there doesn't seem to be anything relevant. I can't believe that it isn't something that somebody else hasn't done before though...

I don't need exact code - just suggestions for any better general approaches. I don't need "super-accuracy" either. As a sidenote, I'd ideally like the approach to be applicable to two or more polygons too.

Thanks for any suggestions!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

踏月而来 2024-10-11 15:17:59

我无法真正发布任何示例代码,因为我现在正在使用 iPhone 工作,但我确实有一个建议(不知道它是好是坏)...

对于每一行,确定每个顶点的位置(百分比)沿线。

获取每条线的这些值后,使用所有其他线的百分比值沿每条线计算新顶点。

此时,每条线应包含相同数量的顶点,并且每条线的第 N 个顶点与每隔一条线的第 N 个顶点直接对应。

现在只需对每条线的顶点 0 进行平均即可得到“平均”线的顶点 0。对每条线的 vertex1 重复此操作,等等。

这应该适用于线和多边形。

请注意,如果您可以确定每条线的准确度值,则还可以采用加权平均算法。过去,我在尝试平均两条线时使用过这种方法。我们能够对每条线进行加权,通常为 50:50,但也可以一直达到 100:0 或 0:100,具体取决于来源的准确性。

我回去重读了你的问题,发现你已经谈到了插值。您所说的这样做的方式似乎可以在计算插值点(固定间隔点)的平均值之前平滑或概括线条。按照我的方法,您将首先加密每行,然后计算平均值。看起来这可能更准确,但也可能不是。

I can't really post any sample code as I am working from my iPhone right now, but I do have a suggestion (don't know if it's good or bad) ...

For each line, determine each vertex's position (percentage) along the line.

After getting those values, per line, compute new vertices along each line using all of the OTHER lines' percentage values.

At this point, each line should contain the same number of vertices and the Nth vertex of each line corresponds directly with the Nth vertex of every other line.

Now just average vertex 0 for every line to get vertex 0 of the "averaged" line. Repeat for vertex1 of each line, etc.

This should work for lines as well as polygons.

Note that you could also employ a weighted averaging algorithm if you could determine an accuracy value for each line. In the past I have used this approach when trying to average two lines. We had the ability to allow each line to be weighted, typically 50:50, but could go all the way to 100:0 or 0:100, depending on the accuracy if the sources.

I went back and reread your question and saw that you already talked about interpolation. The way you talked about doing it seems like it could smooth or generalize the lines before computing the averages of the interpolated points (the fixed interval points). With my approach you would be densifying each line first and then computing the averages. It seems like that might be more accurate, but maybe not.

凝望流年 2024-10-11 15:17:59

好的,我已经重新阅读了这里的所有内容并查看了图像。确实有唯一的方法可以做到这一点,并且已经有所说明。您必须对采样进行归一化,然后将移动多项式平均公式应用于 n 个结果。

正确地做到这一点需要大量的数学计算,这给我们带来了一个问题:您的速度要求是多少?

插值公式如下:http://en.wikipedia.org/wiki/Interpolation

一旦您将每条线标准化或“重新整形”为预定的采样率,您就可以对它们进行平均。

也看看这个答案:哪种算法可以有效地找到路径一定距离内的一组点?

Ok, I have re-read everything here and looked at the image. There is only way way to do this really, and it's been somewhat stated. You have to normalize your sampling and then apply a moving polynomial average formula to the n results.

The math to do this properly is intense, which bring us to the question of what are you speed requirements?

The formulas for interpolation are here: http://en.wikipedia.org/wiki/Interpolation

Once you have normalized or "re-shaped" each line into a predetermined sample rate, then you can average them.

Have a look at this answer too: Which algorithm can efficiently find a set of points within a certain distance of a path?

笔落惊风雨 2024-10-11 15:17:59

我建议您对已知点应用线性回归。这将给出通过它们的直线平均值。

I suggest you apply linear regression to the known points. That will give the straight line average through them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文