[Qgis-user] aggregate polygon overlay

Richard Greenwood richard.greenwood at gmail.com
Tue Feb 17 08:20:59 PST 2026


Here's another postgis solution. I started with your original QGIS union
which has 12 polygons. Then in postgis:

select st_union(geom) as unique_geom, string_agg(attrib, ',') as
concatenated_attribute
from test
group by geom;

This is an aggregate query the groups by geometry. The "magic" is the
string_agg function which concatenates the "attribute" field. The query
produces 7 rows (below). The string_agg() function also accepts an ORDER BY
if that's important to you.
[image: image.png]




On Tue, Feb 17, 2026 at 8:23 AM Karl Magnus Jönsson via QGIS-User <
qgis-user at lists.osgeo.org> wrote:

> Hi Simon!
>
> Seems like a common problem that GIS should handle easy, but it is perhaps
> not that easy. I had a similar problem that ended up in below. I have my
> data in Postgres + PostGIS so it is handled by the database in in a view.
> The code disassembles the polygons in the rings, union the rings and then
> build polygons again from the lines. Then I do a join with the original
> data (in this case not exactly) based on location on the centerpoint. In
> your case I would do a suitable group by and concatenate the attributes.
> Hope this helps even it is not QGIS.
>
>
>
> WITH orings AS (
>
>          SELECT
> st_exteriorring((st_dumprings((st_dump(omr.geom)).geom)).geom) AS geom
>
>            FROM qdp2.omr
>
>         ), oboundaries AS (
>
>          SELECT st_union(orings.geom) AS geom
>
>            FROM orings
>
>         ), opoly AS (
>
>          SELECT (st_dump(st_polygonize(oboundaries.geom))).geom AS geom
>
>            FROM oboundaries
>
>         )
>
> SELECT row_number() OVER () AS id,
>
>     p.namn,
>
>     'delområde'::text AS delomr,
>
>     p.plan_uuid,
>
>     p.status,
>
>     p.publicerad,
>
>     op.geom
>
>    FROM opoly op,
>
>     qdp2.plan_omr po,
>
>     qdp2.plan p
>
>   WHERE st_contains(po.geom, st_pointonsurface(op.geom)) AND po.plan_uuid
> = p.plan_uuid
>
>
>
> Med vänliga hälsningar
>
>
>
> *Karl-Magnus Jönsson*
>
>
>
> *Från:* QGIS-User <qgis-user-bounces at lists.osgeo.org> *För *Simon
> Dietmann via QGIS-User
> *Skickat:* den 17 februari 2026 15:01
> *Till:* qgis-user <qgis-user at lists.osgeo.org>
> *Ämne:* [Qgis-user] aggregate polygon overlay
>
>
>
> Dear list,
>
>
>
> I am trying to solve the following problem:
>
>
>
> I have one polygon layer with many polygons  that are in many cases
> overlapping and with different attribute valus, e.g. a, b, c:
>
>
>
> My goal is to generate a polygon layer with polygons for every overlap
> constellation containing a concat string of those attributes, in this
> example seven polygons with the attributes a, b, c, ab, bc, ac, abc.
>
>
>
> I started with a union of my original layer, the result is a layer with 12
> polygons where overlapping areas of the original polygons result in
> overlapping intersections containing one of the original attributes each,
> for example in the middle, there are 3 polygons, one with a, one with b and
> one with c.
>
>
>
> How is it possible to summarize those overlapping polygons into one
> polygon each with all the attributes, given that there is a large number of
> polygons and different attributes?
>
>
>
> Thank you for any hints,
>
>
>
> regards
>
>
>
> Simon
>
>
>
> i.A. Simon Dietmann
> Projektleiter | Geograph
>
> PGNU Planungsgesellschaft Natur & Umwelt mbH
> Amtsgericht Frankfurt am Main, HRB 111938;
> Geschäftsführer: Dr. Benjamin Hill, Dorit Thurm, Sebastian Braun
> Hamburger Allee 45 +++ 60486 Frankfurt am Main
> Durchwahl: +49 69 952964-32 +++ Fax: +49 69 952964-99
> E-Mail: dietmann at pgnu.de +++ Web: www.pgnu.de
>
> > Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte
> Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder
> diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die
> unbefugte Weitergabe dieser Mail sind nicht gestattet.
> > This e-mail may contain confidential and/or privileged information. If
> you are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and destroy this e-mail. Any
> unauthorised copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>


-- 
Richard W. Greenwood
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260217/1bc6dfbd/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 50063 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260217/1bc6dfbd/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 8911 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260217/1bc6dfbd/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 43782 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260217/1bc6dfbd/attachment-0005.png>


More information about the QGIS-User mailing list