首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >计算多个纬度/经度坐标对的中心点

计算多个纬度/经度坐标对的中心点
EN

Stack Overflow用户
提问于 2011-07-13 05:11:17
回答 21查看 130.7K关注 0票数 168

给定一组纬度和经度点,我如何计算该集合中心点的纬度和经度(也就是将视图集中在所有点上的一个点)?

编辑:我使用过的Python解决方案:

代码语言:javascript
复制
Convert lat/lon (must be in radians) to Cartesian coordinates for each location.
X = cos(lat) * cos(lon)
Y = cos(lat) * sin(lon)
Z = sin(lat)

Compute average x, y and z coordinates.
x = (x1 + x2 + ... + xn) / n
y = (y1 + y2 + ... + yn) / n
z = (z1 + z2 + ... + zn) / n

Convert average x, y, z coordinate to latitude and longitude.
Lon = atan2(y, x)
Hyp = sqrt(x * x + y * y)
Lat = atan2(z, hyp)
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6671183

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档