我将多边形geom作为显示第一个经度,纬度的文本...我正在创建GeoJSON并在传单上绘图...但是传单标准第一个纬度然后是经度。我正在使用PostGIS如何更改多边形...如果我有点几何,我可以很容易地更改st_x
,st_y
以获得点....但是我想要更改为多边形的整体边界,我创建的goem是
[[72.96699,31.96872],[72.9679,31.9669]]
虽然我想转换为
[[31.96872,72.96699],[31.9669,72.9679]]
整体而言我的查询是
(SELECT row_to_json(fc)
FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features
FROM (SELECT 'Feature' As type
, st_asgeojson(lg.geom , 5 ,0)::json As geometry
, row_to_json((SELECT l FROM (SELECT id, distt_name) As l
)) As properties
FROM (SELECT gid as id, distt_name , geom FROM tbl_districts
where distt_name like '%') As lg) As f )
As fc)
答案 0 :(得分:1)
GeoJSON specifies x,y not y,x. So it's already longitude,latitute。看这里。
SELECT ST_AsGeoJSON( ST_MakePoint(1,2) );
st_asgeojson
--------------------------------------
{"type":"Point","coordinates":[1,2]}
(1 row)
您应该使用jsonb_build_object
和ST_AsGeoJSON
生成GeoJSON。