Reputation: 101
Given what I know about how Latitude and Longitude works, metric distances between two points at constant Longitude, but different Latitude, should be different. However, this is not what the Python library Geopy reflects. For example:
from geopy.distance import distance
point_a = (0,0); point_b = (1,0)
point_c = (0,75); point_d = (1,75)
print("a - b ", distance(point_a, point_b).m)
print("c - d ", distance(point_c, point_d).m)
This returns:
>>> a - b 110574.38855779878
>>> c - d 110574.38855779878
I feel like these distances should not be the same, or am I missing something critical about how these distances are calculated? Does the distance function not set the projection to WGS84/4326 by default, but instead use some local projected coordinate system?
Upvotes: 0
Views: 4238
Reputation: 101
Never mind, I was getting the coordinate order backwards:
from geopy.distance import distance
point_a = (0,0); point_b = (0,1)
point_c = (75,0); point_d = (75,1)
print("a - b ", distance(point_a, point_b).m)
print("c - d ", distance(point_c, point_d).m)
Now this returns what I would expect...
a - b 111319.49079327357
c - d 28901.663548048124
I feel like we all just need to agree that all coordinate order should be (x,y). (Lat, Lon) is outdated and never used in analysis.
Upvotes: 2
Reputation: 152
Yup, according to the docs, geopy defaults to geodesic distance, but has capabilities for WGS84 as well.
Geopy can calculate geodesic distance between two points using the geodesic distance or the great-circle distance, with a default of the geodesic distance available as the function
Upvotes: 0