如何找到多个地理点的中心?
如果我有一系列经度和纬度点,我将如何计算所有这些点的中心?
If I have a series of points as longitude and latitude, how would I calculate the center of all of those points?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可能正在寻找由点定义的简单多边形的质心。 该文章提供了有关如何计算各种几何形状的信息。
You're probably looking for the centroid of the simple polygon defined by the points. There is information on how to calculate it for various geometries in that article.
如果您按照以下形式提出问题,Wolfram Alpha 将为您执行此操作:
具有顶点的多边形的质心:(X,Y),(X,Y),(X,Y),(X,Y),(X,Y)等。
只需记住转换每个“(X,Y)”先化成十进制形式。
Wolfram Alpha 将以十进制形式返回答案,然后您可以将其复制并粘贴到 Google 地球中。
Wolfram Alpha will do this for you if you ask the question in the following form:
centroid of polygon with vertices: (X, Y), (X, Y), (X, Y), (X, Y), (X, Y), etc.
Just remember to convert each "(X, Y)" into decimal form first.
Wolfram Alpha will return the answer in decimal form, which you can then copy and paste into Google Earth.
不要只取平均值。
您可以转换为 3d 坐标,然后取平均值(x、y 和 z 坐标),然后将其投影回球体并将其转回纬度/经度。
球面坐标上的维基百科页面有转换算法。
Don't just take averages.
You can convert to 3d coordinates, then take the average (of x,y, and z coords), then project it back onto the sphere and turn that back into lat/long.
The wikipedia page on spherical coordinates has conversion algorithms.
首先,您需要定义您感兴趣的中心。记住这两点:
中心很容易,它位于它们之间。 现在添加第三点:
中心是否仍在 A 和 B 之间的中间,或者是否因为 C 而偏重于 A? 那么中心是最接近所有点的点还是仅是封闭多边形上的点?
另外,由于它是长/纬度,因此您要处理的点位于球体的表面上,因此长 0 度和长 90 度之间的距离在 lat 0 处比在 lat 45 度处大得多。
First off, you need to define which centre you're interested in. Take these two points:
The centre is easy, it's halfway between them. Now add a third point:
Is the centre still halfway between A and B or is it weighted towards A because of C? So is the centre the point nearest to all points or just the points on the enclosing polygon?
Also, as it's long/lat you're dealing with the points are on a surface of a sphere so the distance between long 0 and long 90 degrees is much greater at lat 0 than at lat 45 degrees.
Geomidpoint 涵盖了 3 种不同的计算方法。
Geomidpoint covers 3 different methods for calculating this.
有几个人回答说取纬度和经度的平均值。 这是一个正确的想法,但是在这个领域的意思更加复杂。
纬度/经度表示本质上是人为的,并且具有不连续性(在两极,如果不小心的话,则在本初子午线的对面),因此它采用的方式似乎(对我来说)不太可能有合理的几何解释。 我认为你需要做一些事情,比如对地心坐标中的向量进行平均,然后对结果进行归一化以将其放回球体上。
希望有这方面经验的人能够更具体地发表评论。
Several people have answered to take the mean of the latitudes and longitudes. This is sort of the right idea, but means are more complicated on the sphere.
The latitude/longitude representation is essentially artificial and has discontinuities (at the poles, and opposite the prime meridian if you aren't careful), so it taking means in it doesn't seem likely (to me) to have a sensible geometric interpretation. I think you need to do something like averaging vectors in earth-centered coordinates, and then normalizing the result to put it back on the sphere.
I hope someone with more experience in these matters can comment more concretely.
请参阅 Moe 的答案,尽管如果您的点分布在全球各地,您必须确保您的中心倾向于本初子午线而不是国际日期变更线。
See Moe's answer, although if your points are distributed across the globe, you'll have to be satisfied that your center tends towards the Prime Meridian and not the International Date Line.