将纬度替换为经度
Posted
技术标签:
【中文标题】将纬度替换为经度【英文标题】:Replace latitude to longitude 【发布时间】:2017-11-25 14:22:52 【问题描述】:我将多边形几何图形作为显示第一个经度、纬度的文本......我正在创建 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)
【问题讨论】:
【参考方案1】:GeoJSON is accepted by Leaflet.
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。
【讨论】:
以上是关于将纬度替换为经度的主要内容,如果未能解决你的问题,请参考以下文章