I have compared some distance calculations between geopy and PostGIS ST_Distance_Sphere, and it seems that PostGIS ST_Distance uses a calculation that is similar to the great circle distance rather than Vincenty.

Geopy Vincenty (Most accurate) using geopy

>>> from geopy.distance import great_circle, vincenty
>>> p1=(32.083659,34.806480)
>>> p2=(32.0843373,34.8065365)
>>> vincenty_distance = vincenty(p1, p2).meters
>>> print vincenty_distance

Great Circle (less accurate) using geopy

>>> great_circle_distance = great_circle(p1, p2).meters
>>> print great_circle_distance

PostGIS ST_Distance_Sphere, Unknown Algorithm:

=> SELECT ST_Distance_Sphere(
          ST_SetSRID(ST_MakePoint(34.806480, 32.083659), 4326),
          ST_SetSRID(ST_MakePoint(34.8065365, 32.0843373), 4326));
(1 row)

Does PostGIS have a Vincenty Distance calculation?


Yes, use ST_Distance_Spheroid, or use a cast to the geography type

SELECT ST_Distance('POINT(34.806480 32.083659)'::geography, 
                   'POINT(34.8065365 32.0843373)'::geography);

Hard to tell from the coordinates you are using, but make sure the longitude comes first, the latitude comes second in the POINT syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.