1

I'm using a vector tile layer in QGIS, and certain symbology effects don't work very well due to (I presume) how certain features (in this case the river) have been split up across multiple vector tiles. In the example below I'm using a geometry generator expression to create buffered lines around the river edge, but the way the river polygon has been split into parts means that these buffers start and stop at certain points along the length of the river.

screenshot 1

Upon inspection, the river is indeed split into different polygons along its length. Is there a way (maybe within the geometry generator) to merge these polygons when determining the symbology (and so remove the buffer lines mid-river)?

screenshot 2

Alternatively, if I were to get my own polygon for the river (or other features), can I place this between some of the vector tile layers (eg below the roads but above the buildings), or do all the layers within the vector tile layer stay together (if that makes sense)?

1 Answer 1

1

You can kind of "merge" all polygons with geometry generator using the expression buffer (collect ($geometry),0). Thus in your expression, simply replace $geometry with this expression (see below for the exact expression).

Red outlined: segments of the river; blue lines generated with the expression and Geometry generator: enter image description here

So the whole expression to generate the blue lines looks like:

segments_to_lines(
    collect_geometries(
        array_foreach(
            generate_series(0,4,0.3),
            with_variable(
                'distance',
                10*exp(@element)-10,
                buffer(
                    buffer (
                        collect ($geometry),
                        0
                    ),
                    -@distance
                )
            )
        )
    )
)
3
  • Thanks for the response - do you know if this works with vector tiles? I've tried it with my example posted above, but it just seems to make the geometry generator layer invisible :( Mar 15, 2022 at 21:01
  • I don't know if there is a difference with vector tiles. Shouldn't be different, though?
    – Babel
    Mar 15, 2022 at 21:32
  • I'd hope not, but I can't get it working for me so I fear it might be Mar 15, 2022 at 21:48

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.