postgresql 如何从 PostGIS 获取地球上两点之间的距离?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31213790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get distance between two points on Earth from PostGIS?
提问by Nathan Long
I'm getting an unexpected value from a PostGIS distance query, and I'm not sure why. I'm trying to find the distance between two points on Earth.
我从 PostGIS 距离查询中得到了一个意外的值,但我不知道为什么。我试图找到地球上两点之间的距离。
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.7 公里。
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. Something is obviously amiss.
但是,如果我使用我正在使用的开源库或使用几个在线计算器中的任何一个来计算这个距离,我会得到 538.6km。显然有些不对劲。
What am I doing wrong?
我究竟做错了什么?