-
Notifications
You must be signed in to change notification settings - Fork 25
Description
I need to compute the long distances (>>1000km) between two points given their coordinates (latitude, longitude) so I used the euclidean_distance function. The points are:
- P1(21.42, -158.15)
- P2(-14.02, -75.73)
I computed the distance using the following code:
using Geodesy
# Define latitude and longitude for the points
P1 = LLA(21.42, -158.15)
P2 = LLA(-12.50, -76.80)
# Calculate the Euclidean distance
distance = euclidean_distance(P1, P2) / 1e3
println("Euclidean Distance: $distance km")
Te output was: Euclidean Distance: 8748.3453257146 km
However, I know that the true distance should be approximately 9650 km. I confirmed this with online latitude/longitude distance calculators like NOAA Lat/Lon calculator which gave a result of approximately 9633 km.
I also tried using the Geodesics.jl package, and it provided a more accurate distance:
using Geodesics
# Define the major radius and flattening factor for the WGS84 ellipsoid
a, f = Geodesics.EARTH_R_MAJOR_WGS84, Geodesics.F_WGS84
# Calculate the geodesic distance
dist, az, baz = Geodesics.inverse(deg2rad.((-158.15, 21.42, -76.80, -12.50))..., a, f)
println("Geodesic Distance: $(dist / 1e3) km")
The output was: Geodesic Distance: 9642.42096397771 km
I have tested the euclidean_distance function with short distances, and it seems accurate. However, the error increases with long distances, so I guess there is some error propagation when dealing with longer distances. Please let me know if I am using the function incorrectly or if this is an actual computational error.