I've tried several ways of measuring the distance between two points in my Django application and comparing the results to a reliable measurement. My numbers are way off. For example, I'm assuming the real distance between Dublin and Liverpool is ~217 km as reported by Google Maps:
Using geopy
(should be extremely accurate):
>>> from geopy.distance import distance
>>> dublin = (-6.270447, 53.339791)
>>> liverpool = (-2.991028, 53.402061)
>>> distance(dublin, liverpool).km
362.70989455939394
Using Django's GEOS API (less accurate linear calculation):
>>> from django.contrib.gis.geos import Point
>>> dublin = Point(-6.270447, 53.339791, srid=3857)
>>> liverpool = Point(-2.991028, 53.402061, srid=3857)
>>> dublin.distance(liverpool)*100
328.00101418228877
EDIT: Using a better projection for this area (UTM 30N) yields almost the same result:
>>> dublin.transform(32630)
>>> liverpool.transform(32630)
>>> dublin.distance(liverpool)*100
328.32200116442266
In both cases I'm off by over 100km! Measuring small distances (<1km) is just as inaccurate. What am I doing wrong here!?
geopy
docs or in other answers, and the Vincenty distance I get should be accurate on the mm level.dublin.distance(liverpool)*100
<-- The fact that you had to multiply by 100 instead of 1000 should tell you something suspicious is going on here.