简体   繁体   English

如何从PostGIS获取地球上两点之间的距离?

[英]How can I get distance between two points on Earth from PostGIS?

I'm getting an unexpected value from a PostGIS distance query, and I'm not sure why. 我从PostGIS距离查询中得到了一个意外的值,我不知道为什么。 I'm trying to find the distance between two points on Earth. 我想找到地球上两点之间的距离。

SELECT ST_Distance(
  ST_Point(50.7678,6.091499)::geography,
  ST_Point(52.525592,13.369545)::geography
) as distance;

... returns 827757.672533206 , or about 827.7km. ...返回827757.672533206 ,或大约827.7km。

However, if I calculate this distance with an open source library I'm using, or using any one of several online calculators, I get 538.6km. 但是,如果我用我正在使用的开源库计算这个距离,或者使用几个在线计算器中的任何一个,我得到538.6km。 Something is obviously amiss. 有些东西显然不对劲。

What am I doing wrong? 我究竟做错了什么?

The result is correct, the input is not. 结果是正确的,输入不是。 ST_Point accepts input as (lon,lat) while you're verifying it as (lat,lon) . 当您将其验证为(lat,lon) (lon,lat) ST_Point接受输入为(lon,lat) (lat,lon)

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

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