【发布时间】:2021-06-10 12:04:32
【问题描述】:
我是地理空间 python 库和距离计算的新手,我想避免可能非常昂贵的 for 循环。
我有纬度和经度列表,我需要沿轨迹顺序创建另一个固定 dist=5 的点列表。
list_x = []
list_y = []
r_val = 5
long[0] = long_start
lat[0] = lat_start
for i,j in zip(range(len(long)), range(len(lat))):
for i,j in zip(range(len(long)), range(len(lat))):
long_cent = long[i]
lat_cent = lat[j]
if ( (np.sqrt((long[i+1]-long_cent)**2 + (lat[j+1]-
lat_cent)**2)>= np.ceil(r_val)) ):
list_x.append(long[i])
list_y.append(lat[j])
I need to update the i,j of the first for loop and compute the
distances of the second for loop starting form the update (i,j)
我需要一个新的列表 d_long, d_lat 包含 dist=5 的点的纬度和经度 如下
d_long = [long_a,long_d,long_g,long_i]
d_lat = [lat_a,lat_d,lat_g,lat_i]
在哪里
(long_d,lat_d) is the first element that dist=5 from (long_a,lat_a),
(long_g,lat_g) is the first element that dist=5 from (long_d,lat_d),
(long_i,lat_i) the following element that dist=5 from (long_g,lat_g)
您能否建议任何有效的解决方案,使用 pandas、geopandas 或除 python 循环之外的任何其他灵魂?
【问题讨论】:
-
不清楚您要的是什么。请提供一个示例,并展示一个具有具体最小输入和预期输出的参考实现。
标签: python pandas numpy geospatial geopandas