TransWikia.com

Variable width buffer in QGIS

Geographic Information Systems Asked on June 7, 2021

Is there any built-in tool in QGIS that I can use to buffer points to a variable size (I want to circles around the points, with widths dependent on an attribute in the point layer)?

The Vector/Geoprocessing/Buffer tool only lets me set a fixed buffer size for all features.

3 Answers

In the built-in Buffer tool, the field selection has been replaced by the familiar Data defined override icon. Simply click this and select the relevant field, or create an expression using the field.

data override

results

That said, @babel's solution is excellent in that it does not create a separate layer for the buffers. If you plan to add to or edit the points layer, you won't need to re-run the buffer each time.

If you prefer a standalone polygon output layer, the built-in tool will suffice.

Correct answer by JoshC on June 7, 2021

There is another solution to this: you can use geometry generator to style your pointlayer. As geometrytype, choose polygon and than define an expression like this one:

buffer($geometry, "your_field" )

The advantage: you can play around with the parameters of the expression and observe changes in realtime (like increasing the buffer size by a multiplication factor to get ideal size).

If you want to make your buffer permanent as a separate layer, you can use the "geometry by expression" algorithm from the processing toolbox: https://docs.qgis.org/3.10/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#geometry-by-expression

See the screenshot, where I used the fid to scale the buffer - this does not really make sense, it's just for demonstration purpose. Instead of fid insert the name of the attribute field you want to use (in the expression editor under fields and values in the column in the middle). I added a multiply-factor of 500 - otherwise the buffer would have been to small to be seen.

enter image description here

Answered by Babel on June 7, 2021

Alternatively, method #3:

For QGIS, using the new virtual layer with the SQL script in the form window -

SELECT id, ST_Buffer(geometry, variable*0.001) geom_varbyffer, variable
FROM <table_name>
ORDER BY id;

where a variable is a field with the name "variable", in which the values of buffer zones' sizes are located

  1. be sure to replace with your field name;
  2. be sure to set the necessary size of the constant buffer;
  3. be sure to re-save the obtained result.

Answered by Cyril Mikhalchenko on June 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP