13

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?

15

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.

2
  • 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 Sep 10 '19 at 15:52
  • 1
    Realised this is possible with the inverted polygon style thus requiring no code =) – James B Sep 12 '19 at 8:19
12

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, privacy policy and cookie policy

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