我正在使用 PostGIS 计算用户定义线串的长度。该列定义为 geography(LineString,4326)
。
线串由此 GeoJSON 表示:
"track": {
"type": "LineString",
"coordinates": [
[
49.364325571013,
16.785549033597
],
[
49.363254969491,
16.642149334451
]
]
}
SELECT ST_Length("geography") FROM table;
返回 15945.7486086962,但 Google map 上测量的长度约为 10 公里。
我做错了什么?如何测量长度以获得与 Google map 相同的值?
最佳答案
我认为这是切换 x,y 位置的经典问题。
考虑 x,y:
SELECT
ST_Length(
ST_GeogFromText('SRID=4326;LINESTRING(49.364325571013 16.785549033597,49.363254969491 16.642149334451)'),true);
st_length
------------------
15869.9069442778
和“相同”的 LineString 切换到 y,x ..
SELECT
ST_Length(
ST_GeogFromText('SRID=4326;LINESTRING(16.785549033597 49.364325571013,16.642149334451 49.363254969491)'),true)
st_length
------------------
10416.8606521809
关于postgresql - PostGIS:线串长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58132589/