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.

Taras
  • 32,823
  • 4
  • 66
  • 137
she_weeds
  • 12,488
  • 1
  • 28
  • 58

2 Answers2

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.

Taras
  • 32,823
  • 4
  • 66
  • 137
she_weeds
  • 12,488
  • 1
  • 28
  • 58
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.

Taras
  • 32,823
  • 4
  • 66
  • 137
Kartograaf
  • 2,902
  • 7
  • 23
  • Is this in SQL? The parameter you refer to doesn't seem to exist with geometry generator expressions (for buffer(), anyhow). – she_weeds Oct 02 '19 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 03 '19 at 09:48