我有一个表,该表具有三列:id,geometry和一个text列,它是一个由几列组成的聚合数组。我想创建一个geojson对象,但它不允许我这样做。你能帮我吗!
T1
id | tag_frequency | geom
1 | {"[frame,1]", "[big,3]"} | 00000046875
这是我用来创建对象并写入文件的查询
copy (SELECT jsonb_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT jsonb_build_object(
'type', 'Feature',
'id', id,
'geometry', ST_AsGeoJSON(geom)::jsonb,
'properties', to_jsonb(inputs) - 'id' - 'geom'
) AS feature
FROM (
SELECT * FROM T1
) inputs
) features)to '...\test.geojson';
但是,已使用以下查询从另一个表中检索了标签列,以使与每个ID相关联的所有单词的出现频率都达到这一水平。
SELECT id, geom, array_agg('[' || tags || ',' || frequency || ']')
as tag_frequency
FROM
(SELECT id, geom, tags, count(tags) AS frequency
FROM tt
GROUP BY id, geom, tags order by tags) AS RES
GROUP BY id, geom;