Geom到简单的json

时间:2017-11-21 18:20:12

标签: json postgresql postgis

我在postgres数据库中有geom。当我使用此查询时

SELECT   ST_AsGeoJSON(st_simplify(geom,0.01))::json  As geometry FROM tbl_tehsils 

结果显示为

"{"type":"MultiPolygon","coordinates":[[[[72.3847874560001,33.4222288170001],[72.4486151570001,33.390380325], (...)"  

虽然我喜欢将结果创建为

[[31.7143740770001,74.6556250200001],[31.256258297,74.244557296]]

我正在使用postgres(postgis)。

1 个答案:

答案 0 :(得分:2)

您可以像这样提取坐标。

select ST_AsGeoJSON(st_simplify(geom,0.01))::json->>'coordinates' from tbl_tehsils ;