相互上下班的30分钟之内的集群地理位置(长/纬度?

问题描述 投票:-1回答:1

我正在尝试对地理位置(长/纬度)进行聚类,在这些地理位置中,聚类中数据点之间的距离应小于或等于30分钟。我可以使用Google Map API计算两点之间的持续时间。如何将30分钟之内互相通勤的站点聚在一起?

python api maps cluster-analysis duration
1个回答
0
投票

目前尚不清楚您要问的是什么,但是据我了解,您正在尝试根据经度和纬度在两个点之间建立关联。

因此,我使用您提到的API比较了A和B两点。您可以使用字典将两个点相互关联。假设我有一堂这样的课:

Point.py

class Point(object):
    def __init__(latitudeToSet, longitudeToSet):
        self.latitude = latitudeToSet
        self.longitude = longitudeToSet
        self.pointsInRange = {}

然后在主程序文件中,可以像这样使用它(作为基本示例):

import Point

def main:

    someNewPoint = Point(0, 0)
    someOtherPoint = Point(1, 1)

    if ( googleAPI.isInRange( (someNewPoint.latitude, someNewPoint.longitude), 
        (someOtherPoint.latitude, someOtherPoint.longitude) ) ):

        someNewPoint.pointsInRange["someOtherPoint"] = someOtherPoint
        someOtherPoint.pointsInRange["someNewPoint"] = someNewPoint

    #From here just check if one point exists in another's dictionary.

    if "someOtherPoint" in someNewPoint.pointsInRange:
        #Do stuff because you know the points are in range.
© www.soinside.com 2019 - 2024. All rights reserved.