Sql 如何在postgres DB中从geom列中获取lat和long
我在postgres DB中有一个名为“building_footprints”的表 请参阅所附图片 并在下面运行查询表Sql 如何在postgres DB中从geom列中获取lat和long,sql,postgresql,postgis,Sql,Postgresql,Postgis,我在postgres DB中有一个名为“building_footprints”的表 请参阅所附图片 并在下面运行查询表 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.the_geom)::json As geometry,
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.the_geom)::json As geometry,
row_to_json((gid, the_geom)) As properties FROM building_footprints As lg
) As f) As fc
查询结果为:
我想将坐标值(坐标):[[[[530500.00039933545400.008863266],)
转换为lat/long。试试这个
SELECT id, the_geom , ST_X(the_geom::geometry), ST_Y(the_geom::geometry) FROM building_footprints;
您应该安装postgis扩展
请参阅:请阅读并接受答案