6

I'm trying to buffer a line using Geometry Generator in QGIS:

buffer($geometry, 3)

However although I've set the Simple Fill join style to miter I can't get the ends of the buffer to be flat.

enter image description here

I wanted to use a polygon for styling (rather than having the line width set to 6 map units) because it's much easier to have a semi-transparent fill with a consistent border and a line fill effect.

Is there any way to set the end cap for polygon styles or using expressions? I notice single_sided_buffer() has a parameter for join style but buffer() does not.

2

2 Answers 2

4

As of the current QGIS 3.22 (LTR) the buffer() function in Expression Builder now has parameters for join type, cap type etc. So by using for example buffer($geometry,2, cap:='flat') one can have a flat-ended geometry generated buffer.

3

If you have line vector file that you want to buffer, you can input it to QGIS tool "Buffer" (Vector -> Geoprocessing Tools)

buffer tool window

The parameter you want to change is called 'END_CAP_STYLE'. Setting it to 1 — Flat should give you the desired result.

2
  • Is this in SQL? The parameter you refer to doesn't seem to exist with geometry generator expressions (for buffer(), anyhow).
    – she_weeds
    Oct 2, 2019 at 22:32
  • 3
    I only just noticed the edit clarifying that this was for the vector geoprocessing tool. The entire point of using the geometry generator is to avoid creating a new, static layer so this doesn't address the question.
    – she_weeds
    Oct 3, 2019 at 9:48

Your Answer

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

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