Reputation: 99
I am getting polygon geom as text which showing the first longitude, latitude ... I am creating GeoJSON and drawing on leaflet... but leaflet standard first latitude then longitude. I am using PostGIS how I can to change in polygon... if I have point geometry it is very easy I can change st_x
,st_y
for point.... but there I want to change to the overall boundary of the polygon, my created goem is
[[72.96699,31.96872],[72.9679,31.9669]]
while I want to convert as
[[31.96872,72.96699],[31.9669,72.9679]]
overall my query is
(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)
Upvotes: 0
Views: 665
Reputation: 1
GeoJSON specifies x,y not y,x. So it's already longitude,latitute. Look here.
SELECT ST_AsGeoJSON( ST_MakePoint(1,2) );
st_asgeojson
--------------------------------------
{"type":"Point","coordinates":[1,2]}
(1 row)
You should generate GeoJSON using jsonb_build_object
and ST_AsGeoJSON
.
Upvotes: 1