Why is Geopy Distance.Distance wrong?

2019-02-14 03:03发布

问题:

From GeoDjango Point Field, I get the following points:

object1.point = "POINT(-113.4741271000000040 53.4235217000000020)"
object2.point = "POINT(-113.5013688000000229 53.5343457999999970)"

Then I calculate the distance using geopy:

from geopy import distance
from geopy import Point

p1 = Point("-113.4741271000000040 53.4235217000000020")
p2 = Point("-113.5013688000000229 53.5343457999999970")
result = distance.distance(p1,p2).kilometers
print result
# 5.791490830933827

But using this tool: http://www.movable-type.co.uk/scripts/latlong.html I get a distance of 12.45km

Why is there such a big discrepancy?

回答1:

You've got lat/long the wrong way round. Try:

p1 = Point("53.4235217000000020 -113.4741271000000040")
p2 = Point("53.5343457999999970 -113.5013688000000229")

Gives me result = 12.466096663282977



标签: python geopy