当前位置:   article > 正文

python地理位置聚类_如何按距离对地理位置列表进行聚类?

python将若干经纬度按距离分类

I have a list of points P=[p1,...pN] where pi=(latitudeI,longitudeI).

Using Python 3, I would like to find a smallest set of clusters (disjoint subsets of P) such that every member of a cluster is within 20km of every other member in the cluster.

Distance between two points is computed using the Vincenty method.

To make this a little more concrete, suppose I have a set of points such as

from numpy import *

points = array([[33. , 41. ],

[33.9693, 41.3923],

[33.6074, 41.277 ],

[34.4823, 41.919 ],

[34.3702, 41.1424],

[34.3931, 41.078 ],

[34.2377, 41.0576],

[34.2395, 41.0211],

[34.4443, 41.3499],

[34.3812, 40.9793]])

Then I am trying to define this function:

from geopy.distance import vincenty

def clusters(points, distance):

"""

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/821608?site
推荐阅读
相关标签
  

闽ICP备14008679号