How to generate GPS coordinates (Lat and Long) from GPS initial point

Viewed 61

an exercise that is not so easy for me. Let me explain briefly: I want to generate/simulate drone-generated GPS coordinates by interpolating between two points(only A is known). That is, knowing the initial lat and long coordinates, the drone speed and the same direction, and the frames obtained for each pair of points (150 frames), how can I compute the distance (in meters) and transform it back into GPS coordinates (lat and long). In simple words, I have point A with lat and long coordinates (for example: 37.537215, 15.068894 ), I have a constant speed of 1 meter per second, and the number of frames (30 per second). Not knowing point B, how do I generate these GPS coordinates between these two points? Thank you in advance for your answer.

My starting point:

Frame Lat Long

1 37.537215 15.068894

A = (37.537215, 15.068894) 
v = 1
fps = 30 
dist_a = row['Frame'] * v / fps 
dist_b = ???
1 Answers

Firstly, to answer this question we need to understand the math portion.

The Earth has a circumference of 40.075 million meters.

Latitude ranges between -90 and 90 degrees and longitude ranges from -180 to 180 degrees.

To change the GPS coordinates of the moving drone simply add the speed of moving drone multiplied by the time its traveled divided by the circumference of the Earth.

import math

# Original GPS coordinates of the drone
A = (37.537215, 15.068894)

# Speed drone is traveling at in meters per second
velocity = 1

# Circumference of the Earth in meters
circumference = 4.075e7

# Angle drone is traveling at in radians 
angle = 0.7854

# Number of frames per second
fps = 30

# Compute distance in meters at a predefined angle
distance = (row['Frame'] * velocity / fps * math.cos(angle), row['Frame'] * velocity / fps * math.sin(angle))

# Convert distance traveled by drone from its original position in meters 
# to latitude and longitude and then add it to the original GPS coordinate
B_lat = A[0] + distance[1] / circumference
B_long = A[1] + distance[0] / circumference

# Make sure latitude is between -90 and 90 and longitude is between -180 and 180
if B_lat > 90:
    B_lat = B_lat % 90 - 90
elif B_lat < -90:
    B_lat = B_lat % 90
    
if B_long > 180:
    B_long = B_long % 180 - 180
elif B_long < -180:
    B_long = B_long % 180
    

B = (B_lat, B_long)

I hope this is of assistance.

Best regards,

Related