PostGIS空间表查询GeoJSON

 查看代码
   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(geom)::json as geometry  
            , (
                SELECT
                    row_to_json(t)
                FROM (
                    SELECT
                       id, user,content
                    ) AS t
                ) AS properties
        FROM test_table 
    ) AS f
) AS fc
posted @ 2026-03-17 13:58  XYSGIS  阅读(13)  评论(0)    收藏  举报