python - 如何使用纬度和经度坐标进行分组?

标签 python machine-learning coordinates classification

我有一个时间序列数据集,其中给出了接送纬度和经度坐标。 由于城市的坐标几乎没有变化,如何在Python中对它们进行分类?

我想分组以便可以应用分类算法。

我粘贴单行纽约市的接送经度和纬度坐标。

-73.973052978515625 40.793209075927734 -73.972923278808594 40.782520294189453

我已将纬度范围固定为 40.6 到 40.9,经度范围固定为 -73.9 到 -74.25

现在,我想将它们分组,以便可以应用分类算法。

最佳答案

例如,您可以将坐标插入称为坐标元组列表中。请注意,我还附加了一些超出范围的坐标。这是代码:

coordinates = [
    (-73.973052978515625,40.793209075927734),
    (-73.972923278808594,40.782520294189453), 
    (-75.9,40.7)
    ]

filtered = list()

# filtering coordinates
for c in coordinates:
    if  -74.25 <= c[0] <= -73.9 and 40.6 <= c[1] <= 40.9:
        filtered.append(c)

print filtered # here you have your filtered coordinates

输出:

[(-73.97305297851562, 40.793209075927734), (-73.9729232788086, 40.78252029418945)]

关于python - 如何使用纬度和经度坐标进行分组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46179253/

相关文章:

macos - Applescript - 获取元素的坐标

android - 如何获得 Android Touch 事件(运动事件)的开始和结束坐标?

algorithm - 将坐标匹配到最近的起点和终点纬度/经度对

python - 使用 Click 制作简洁、可安装的 Python 库

python - 使用词袋方法预测文本

python - 查找 zip 中的第一个 "inf"(固定扩展名)文件

machine-learning - 交叉验证是否用于找到最佳模型/架构或模型/架构的最佳参数?

python - 指定 Pandas get_dummies 的可能值列表

python - 我从 Graph API 得到不完整的输出

python - 在 Pandas 中使用 read_csv 时精度丢失