The QGIS Geometry Generator seems like a nice way to keep data intact while allowing for some creative visualisations.

I have a layer of tesselating polygons that I would like to style as a continuous surface without internal borders.

To dissolve a number of polygons in Spatialite I would use the UNION function, but Union in the Geometry Generator doesn't give a result, ie:

 union($geometry, $geometry)

So is it possible to use the Geometry Generator to show a polygon layer as dissolved, and if so, how?


2 Answers 2


You can now do this with the geometry generator in QGIS 2.99/3.0 by using buffer(collect($geometry), 0) in the expression builder.

The new collect() aggregate function collects all the feature geometries into a multipolygon; buffer() converts it into a single polygon to be styled as such.

EDIT: As indicated by the comment below, the above method does run into limitations when using opacity (as if you still have 3 separate rings in your "merged" polygon it will render 3 times).

In QGIS 3.18 however this is completely solved by the Merged Features rendering option

  • 1
    Is there a way to do this result without collect but as a merge? If you test this on a polygon with 2 features and a semi-transparent simple fill, you'll notice the expression is carried out twice and the fill will be twice as opaque as you designatied.
    – James B
    Commented Sep 10, 2019 at 15:52
  • 1
    Realised this is possible with the inverted polygon style thus requiring no code =)
    – James B
    Commented Sep 12, 2019 at 8:19

I've tried using the Geometry Generator with no success, and decided on a "Virtual layer" and a SQL query

SELECT st_union(geometry)
FROM layer_name

You need to replace "layer_name" with your layer name.

The resulting virtual layer is based on the source layer and will not create any new data.

It's not the geometry generator style, but it should fix your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.