2

I have recently started working with QGIS. Quite new to this software. Anyway, my first task is to create contours from shapefiles using buffers, unions and dissolve functions. This shapefiles are jointed to CSV files where the contour size will be based on.

Problem is, the values in my CSV will need to be changed from time to time, so does the contours created. Is there anyway I can automatically update my contours everytime my CSV file values change?

Babel
  • 71,072
  • 14
  • 78
  • 208
zaido141
  • 61
  • 3

1 Answers1

2

You can do this if you create the buffers either with Virtual layer or Geometry generator.

  1. Virtual layer: does create actual geometries. Use this query:

    select st_buffer (p.geometry, b.size)
    from point as p, buffersize as b
    where p.id = b.id
    
    • Replace point with the name of the layer containing the geometries that you want to buffer.
    • Replace buffersize with the name of the csv layer containing the attribute field size that defines the buffer distance.
    • Both layers should have a field called id that joins them.

For multiple buffer distances, you can create multiple buffers, combining the repeated query with union:

SELECT st_buffer (p.geometry, b.size) as geom 
   from point as p, buffersize as b
   where p.id = b.id
union
SELECT st_buffer (p.geometry, b.size2) as geom 
   from point as p, buffersize as b
   where p.id = b.id
union
SELECT st_buffer (p.geometry, b.size3) as geom 
   from point as p, buffersize as b
   where p.id = b.id

Or use st_collect to combine two buffers, but it will be a multipart feature:

    select  st_collect (st_buffer (p.geometry, b.size), st_buffer (p.geometry, b.size2))...
  1. Geometry generator: does only create the buffers as style, not actual geometries - see here for details. On the layer containing the geometries you want to buffer, create a symbol layer of the type Geometry generator and use the expression buffer ($geometry, size). Replace size with the field from your CSV.
Babel
  • 71,072
  • 14
  • 78
  • 208