Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Geopy Distance.Distance wrong?

Tags:

python

geopy

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?

like image 324
pmah Avatar asked Jun 13 '12 04:06

pmah


1 Answers

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

like image 128
Maria Zverina Avatar answered Sep 25 '22 23:09

Maria Zverina