When verifying the track forecast compared to ground truth, calculating geodesic distance is required. This issue presents a formula or function used in https://github.com/hammad93/hurricane-net/blob/master/hurricane-net.ipynb but when I made it, there were some uncertainties of the correctness. The goal of the issue is to finalize this function, whether changes are necessary or not.
# Define a function to return the distance between two coordinates in nautical miles
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371 # km
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1)
a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \
* math.cos(math.radians(lat2)) * math.sin(dlon/2) * math.sin(dlon/2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
d = radius * c
return d * 0.539957 # km to nautical miles
This problem is nontrivial because the topology of the Earth is not exactly spherical and even projections can lead to errors. A trivial example is on a flat surface.
When verifying the track forecast compared to ground truth, calculating geodesic distance is required. This issue presents a formula or function used in https://github.com/hammad93/hurricane-net/blob/master/hurricane-net.ipynb but when I made it, there were some uncertainties of the correctness. The goal of the issue is to finalize this function, whether changes are necessary or not.
This problem is nontrivial because the topology of the Earth is not exactly spherical and even projections can lead to errors. A trivial example is on a flat surface.