查找多个 lat lng 的中心点

发布于 2024-11-01 09:45:08 字数 66 浏览 2 评论 0原文

我有多个 lat lng,我想要所有这些 lat lng 的中心点.. 就像最接近所有这些 lat lng 的交汇点。

I have multiple lat lng and I want the center point of all this lat lng.. like the meeting point which will be closest to all this lat lng.

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

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

发布评论

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

评论(2

夜唯美灬不弃 2024-11-08 09:45:08

其实有两点不同。请查看此处

  • 重心

地理中点,有时称为重心、质心或质心,是一组点的平均坐标。如果您在地球仪上标记几个点以及地理中点,那么地理中点确实看起来像在中心。想象一下,在地球仪的不同点放置几个重物,然后让地球仪自由旋转,直到地球仪最重的部分被重力拉动,直到其朝下。那么地球上的最低点将是所有加权位置的地理中点。

地理中点是通过查找位置的重心来计算的。位置的纬度和经度将转换为笛卡尔 (x,y,z) 坐标。计算平均 x、y 和 z 坐标。该平均坐标位于地球内部,是真正的质心,可以从地球中心画一条线穿过该点,然后到达地球表面,即地理中点。将平均 x、y 和 z 坐标转换为中点的纬度和经度。

给定的公式假设地球是球形的,并且有海平面点。如果需要更准确的模型,答案就会复杂得多。

  • 最小距离中心

此点可最小化一组点的组合行驶距离。最小距离中心是绝对最小行进距离的点,但它并不试图均衡其他点行进的距离量。

这里有计算器

方法描述此处

请注意,假定地球是球形的。如果需要更高的精度,解决方案就会复杂得多。

Actually, there are two different points. Look here.

  • Center of gravity

The geographic midpoint, sometimes called the center of gravity, center of mass or centroid is the average coordinate for a set of points. If you mark several points on a world globe along with the geographic midpoint, the geographic midpoint does indeed look like it is in the center. Imagine that several weights are placed at various points on a world globe and then the globe is allowed to rotate freely until the heaviest part of the globe is pulled by gravity until it is facing downward. Then the lowest point on the globe would be the geographic midpoint for all of the weighted locations.

The geographic midpoint is calculated by finding the center of gravity for the locations. The latitude and longitude for the locations are converted into Cartesian (x,y,z) coordinates. The average x, y and z coordinate is calculated. This average coordinate lies within the interior of the earth and is the true center of mass, and a line can be drawn from the center of the earth passing through this point then out to the surface of the earth which is the geographic midpoint. The average x, y and z coordinate is converted into the latitude and longitude for the midpoint.

The given formula assumes a spherical earth, and sea-level points. The answer is much more complex if a more accurate model is needed.

  • Center of minimum distance

This point minimizes the combined travel distance from a set of points. The center of minimum distance is the point of absolute minimum travel distance, however it does not attempt to equalize the amount of distance traveled from the other points.

There are calculators here

The methods are described here

Note that sperical earth is assumed. If higher accuracy is needed, the solution would be much more complex.

时光是把杀猪刀 2024-11-08 09:45:08

您需要计算该坐标的平均位置:

float lat=0, lng=0;
for(int i=0; i<num_coords; ++i) {
   lat += lats[i];
   lng += lngs[i];
}

lat /= num_coords;
lng /= num_coords;

当位置之间的距离小于 500 英里(800 公里)时,此方法会非常接近真实的地理中点。

You need to calculated the mean position of that coords:

float lat=0, lng=0;
for(int i=0; i<num_coords; ++i) {
   lat += lats[i];
   lng += lngs[i];
}

lat /= num_coords;
lng /= num_coords;

When the distance between locations is less than 500 miles (800 km), this method gives a close approximation to the true geographic midpoint.

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