使用点值 postgres/postgis 更新多边形
update polygon with values of points postgres/postgis
我有多边形和点。现在我想合并点的一个特定属性列(如果它们与多边形相交)并将其添加到 "parent" 多边形的新列中。
以下查询已经有效:
select polygons.id, (concat(string_agg(points.desc, '; '))) AS sum
from polygons
left join points
on ST_Intersects(polygons.geom, points.geom)
group by polygons.id;
但是如何更新多边形?
这行不通:
update polygons set description = foo
from (
select polygons.id, (concat(string_agg(points.desc, '; ')))
from polygons
left join points
on ST_Intersects(polygons.geom, points.geom)
group by polygons.id) as foo;
希望你有一些提示...
很抱歉这个简单的问题。这就是它的工作原理:
update polygons
set description = select(concat(string_agg(points.desc, '; ')))
from points
where ST_Intersects(points.geom, polygons.geom));
问题已解决...
我有多边形和点。现在我想合并点的一个特定属性列(如果它们与多边形相交)并将其添加到 "parent" 多边形的新列中。
以下查询已经有效:
select polygons.id, (concat(string_agg(points.desc, '; '))) AS sum
from polygons
left join points
on ST_Intersects(polygons.geom, points.geom)
group by polygons.id;
但是如何更新多边形?
这行不通:
update polygons set description = foo
from (
select polygons.id, (concat(string_agg(points.desc, '; ')))
from polygons
left join points
on ST_Intersects(polygons.geom, points.geom)
group by polygons.id) as foo;
希望你有一些提示...
很抱歉这个简单的问题。这就是它的工作原理:
update polygons
set description = select(concat(string_agg(points.desc, '; ')))
from points
where ST_Intersects(points.geom, polygons.geom));
问题已解决...