I am using postgis to calculate distance between 2 geo co-ordinates.
select st_distance(
'POINT(15.651955 73.712769)'::geography,
'POINT(14.806993 74.131451)'::geography) AS d;
It's returning me 53536.743496517meters which is approximately equal to 54km, but the actual distance is 103km which I have calculated via http://boulter.com/gps/distance/
Am I doing anything wrong in the query ?
POINT() takes its arguments in longitude, latitude. Swap your arguments.
select st_distance(
'POINT(73.712769 15.651955)'::geography,
'POINT(74.131451 14.806993)'::geography) AS d;
st_distance
--
103753.197677054
I make this mistake regularly, because I think in terms of latitude and longitude, not longitude and latitude.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With