Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何在postgres DB中从geom列中获取lat和long_Sql_Postgresql_Postgis - Fatal编程技术网

Sql 如何在postgres DB中从geom列中获取lat和long

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,

我在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,
    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扩展

请参阅:

请阅读并接受答案