简体   繁体   English

postgis st_distance返回不正确的结果

[英]postgis st_distance returning incorrect results

I am using postgis to calculate distance between 2 geo co-ordinates. 我使用postgis来计算2个地理坐标之间的距离。

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/ 它返回我53536.743496517米,大约等于54km,但实际距离是103km,我通过http://boulter.com/gps/distance/计算

Am I doing anything wrong in the query ? 我在查询中做错了吗?

POINT() takes its arguments in longitude, latitude. POINT()在经度,纬度中获取其参数。 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. 我经常犯这个错误,因为我认为在纬度和经度方面,而不是经度和纬度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM