【发布时间】:2020-11-13 15:57:50
【问题描述】:
我有一个带有纬度、经度和 100K+ GPS 点的 pandas 数据框。
df = pd.DataFrame({'lat': [41.260637, 45.720185, 45.720189, 45.720214, 45.720227, 46.085716, 46.085718, 46.085728, 46.085730, 46.085732],
'lng': [2.825920, 3.068014, 3.068113, 3.067929, 3.068199, 3.341655, 3.341534, 3.341476, 3.341546, 3.341476],
'measure': [6.30000, -0.375000, -0.375000, -0.375000, -0.375000, 0.000000, 0.000000, 0.555556, 0.714286, 0.645833]})
我想要做的是,对于这些点中的每一个,计算 10 米范围内所有点的测量列的平均值。
我知道如何使用geopy计算两点之间的距离
from geopy.distance import distance
distance([gps_points.lat[3], gps_points.lng[3]], [gps_points.lat[4], gps_points.lng[4]]).m
21.06426497936181
但是我将如何迭代行,选择 10m 范围内的点并对度量进行平均?
我猜是某种 groupby,但不知道怎么做。
【问题讨论】:
-
我在 GIS Stack Exchange 上发现了一个类似的问题,但没有得到它的答案:gis.stackexchange.com/questions/251298/…
-
标签: python pandas gps pandas-groupby distance