如何在python中计算几个地理位置的中点 [英] How to calculate the midpoint of several geolocations in python

查看:108
本文介绍了如何在python中计算几个地理位置的中点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个图书馆或一种方法可以计算多个地理位置的中心点?这是我在纽约的地理位置列表,想找到大概的中点地理位置

Is there's a library or a way to calculate the center point for several geolocations points? This is my list of geolocations based in New York and want to find the approximate midpoint geolocation

L = [
     (-74.2813611,40.8752222),
     (-73.4134167,40.7287778),
     (-74.3145014,40.9475244),
     (-74.2445833,40.6174444),
     (-74.4148889,40.7993333),
     (-73.7789256,40.6397511)
    ]

推荐答案

评论之后,我收到了使用相互靠近的坐标,您可以将地球视为局部平坦,并且可以简单地找到质心,就好像它们是平面坐标一样.然后,您只需获取纬度的平均值和经度的平均值即可找到 centroid .

With coordinates that close to each other, you can treat the Earth as being locally flat and simply find the centroid as though they were planar coordinates. Then you would simply take the average of the latitudes and the average of the longitudes to find the latitude and longitude of the centroid.

lat = []
long = []
for l in L :
  lat.append(l[0])
  long.append(l[1])

sum(lat)/len(lat)
sum(long)/len(long)

-74.07461283333332, 40.76800886666667

这篇关于如何在python中计算几个地理位置的中点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆