I have a Numpy array of shape (30000, 2000, 2)
where each row is supposed to have 2000 latitude and longitude points with equal distance from each other and in the same direction. The problem is, each row has missing points. For each row, just the latitude and longitude of the start points and the endpoints (in CRS WSG84) are known and the rest of the points are missing.
For example a single row can be like this:
latlonPoints[0,:] = [(48.778767, -123.903275),?,?,?,...,(49.887672, -122.49999)]
Using the start and endpoints for each row, we can easily calculate the distance (sometimes a few kilometers) and also the angle (bearing) between the two points. Then using the distance and bearing we can generate the rest of the points using geopy or other methods. But, iteration using for loop is too slow for all the rows and all the elements for every single row. What will be the fastest way in python to calculate the missing points? Here is what I have implemented and it works fine but slow:
for idx, row in enumerate(latlonPoints):
lat_start = row[0]
long_start = row[1]
coords1 = (lat_start, long_start)
lat_end = row[2]
long_end = row[3]
bearing, back_azimuth, distance = geodesic1.inv(long_start, lat_start, long_end, lat_end)
step_size = distance/(latlonPoints.shape[1] -1)
latlon_row = []
for i in range (0,latlonPoints.shape[1]):
dist = i * step_size
destination = geodesic(kilometers=dist / 1000).destination(coords1, bearing)
latlon_row.append((destination.latitude,destination.longitude))
latlonPoints[idx,:] = np.array(latlon_row)