QGIS – Creating Buffers Around Lines with Varying Widths

bufferlinepolygonqgisvoronoi-thiessen

My questions is about creating an elongated buffer around various lines and these buffers should run right in the middle of two parallel lines. The problem is that the lines do not have an equal width at all points.
image showing the lines around which the buffer should be placed

To give some more context, different weed control measures were used in different lanes, so I want to visualise the lanes as polygons/buffers so I can use them to extract data from different lanes/treatments.

Best Answer

To create "buffers" along the mid line between irregularily spaced lines, create voronoi polygons:

  1. Densify lines and Extract vertices.

  2. Create voronoi polygons for the densified points

  3. Join the line id to the voronoi polygons, using Field calculator with this expression overlay_intersects ('line',$id)[0]

  4. Aggregate voronoi polygons based on line id (see screenshot 1)

  5. To clip the large buffers at the margin, collect all lines in a multiline, buffer this and intersect it with the voronoi polygons (see screenshot 2 for the result). You can do this e.g. with this expression using Geometry by expression:

    intersection (
       $geometry, 
       buffer (collect_geometries (overlay_nearest ('line', $geometry)),15)
    )
    
  • change the value of 15 for buffer size at the end of line 3
  • change line with the name of your line layer

Screenshot 1, red: initial lines; blue with black dashed lines: buffers (one buffer in yellow is selected): enter image description here

Screenshot 2: enter image description here

Related Question