Distance calculation takes (y, x) instead of (x, y)
See original GitHub issueSo the issue is that distance caluclation (vincenty
and great_circle
) take arguments in the form of
((y, x), (y, x))
instead of ((x, y), (x, y))
. The convention followed by Geopy is consistent with the idea of (Latitude, Longitude)
, but is not conversant with Shapely or Fiona’s idea of the same. Shapely and Fiona will return (x, y)
, or (Longitude, Latitude)
, and I think Geopy should accept that format as default. Perhaps have a Boolean switch that takes the other format. For example, the following pseudocode:
def vincenty(p1, p2, xy=True):
if xy:
p1 = reversed(p1)
p2 = reversed(p2)
# And the rest of the algorithm as usual.
IMHO, this would save a considerable amount of headache. Most answers on Stack Exchange are also oblivious to this (eg: http://gis.stackexchange.com/questions/4022/looking-for-a-pythonic-way-to-calculate-the-length-of-a-wkt-linestring).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Closed by #282 which introduced the aforementioned
lonlat
function.Feel free to bump if this solution does not seem complete.
Python is also famous for preferring to have a single way of doing one thing 😃.
The reason why I decided to not introduce
latlon
is that I believe it would be confusing to the API users: what’s the difference between that and constructing the Point instance directly? The order of coordinates is the same. So which one to choose?The (latitude, longitude) order is spread around the library anyways, this won’t go away. So I believe it’s OK to assume the lat, lon order when the order is not explicitly specified by code (like
lonlat
). Especially considering that this order is documented and is constant across the library.