I am new with geospatial python libraries and distance calculations and I would like to avoid for loops that could be very costly.
I have the lists of the latitude and longitude and I need to create another a list of the points at fixed dist=5 sequentially along the trajectory.
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)
I need a new list d_long, d_lat containing the latitude and longitude of the points with dist=5 as below
d_long = [long_a,long_d,long_g,long_i]
d_lat = [lat_a,lat_d,lat_g,lat_i]
where
(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)
Could you suggest any efficient solution that use, pandas, geopandas, or any other soultion other than python loops?