简体   繁体   中英

How to calculate a distance between cities by postgis?

I'm trying to use postgis for calculate distance between cities. For example, the distance between Moscow and SPb is ~637 km (via measure distance in Google Maps). When I use postgis:

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

then I get 895 km

Can anyone tell me, why such an error in this measurement?

I believe you've reversed the lat/lon in the parameters for your ST_Point s:

geometry ST_Point(float x_lon, float y_lat);

More details at this PostGIS link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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