如何通过postgis计算城市之间的距离?

How to calculate a distance between cities by postgis?

我正在尝试使用 postgis 来计算城市之间的距离。例如,莫斯科和 SPb 之间的距离约为 637 公里(通过 Google 地图中的测量距离)。当我使用 postgis 时:

select ST_Distance(
    ST_Point(59.925632, 30.327239),
    ST_Point(55.750352, 37.615717),
    true
);

那我跑了895公里

谁能告诉我,为什么这个测量会出现这样的错误?

我相信您已经在 ST_Point 的参数中颠倒了 lat/lon:

geometry ST_Point(float x_lon, float y_lat);

此 PostGIS 中的更多详细信息 link