0

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?

Annalix
  • 470
  • 2
  • 6
  • 17
  • 2
    It's unclear what you're asking for. Please provide an example, and show a reference implementation with concrete minimal inputs and expected outputs. – Mad Physicist Mar 12 '21 at 13:11

2 Answers2

0

SOLVED

Explained in "Splitting at a specified distance" in the link How to get equally spaced points on a line in Shapely

In this post how Parsing a WKT-file to convert into a list the equi spaced coordinates

Annalix
  • 470
  • 2
  • 6
  • 17
-2

You can try out this,

for x in range(1,len(long),3#this is the gap):
  d_long.append(long[x])
Shakya Peiris
  • 504
  • 5
  • 11
  • Thanks, but the latitude doesn't have the same gap. I need to compute the euclidean distance such away the latitude and the longitude give me the distance desired. – Annalix Mar 12 '21 at 13:19