user2638158
user2638158

Reputation: 99

Geom to simple json

I have geom in postgres database. When I use this query

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

the result shows as

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

while I like to create result as

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

I am using postgres (postgis).

Upvotes: 0

Views: 132

Answers (1)

JGH
JGH

Reputation: 17906

You can extract the coordinates like this.

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

Upvotes: 2

Related Questions