1

This question has been asked before but none of the provided solutions work for me.

I have a bunch of points. Around the points I have created buffers which overlap to differing degrees.

Overlapping buffers

Each buffer has a feature value of 1, and I would like to add these feature values together where the buffers overlap, like in the image below.

enter image description here

From these new intersecting fields I want to create a raster with the feature count as the burn-in value.

I have tried "intersection" using the buffer shapefile layer as both input and intersection layer. I have also tried "Union" on the buffer shapefile layer, and then "Join attributes by location" with the union layer and the original buffer layer, suggested by AlmaThom here: Split and count overlapping features within a layer.

With both these methods I used count() in the field calculator to calculate the number of buffers that intersect each buffer.

The problem with this method is that it does not cut out new fields where the buffers intersect and count their overlapping features. It just sums the features of the buffers that are touching. This is what the raster output looks like:

enter image description here

Supposedly one can do this using the Sextante plugin but it does not seem to be available for QGIS 3.0. Another option would be to use QGIS Processing Toolbox | SAGA | Vector polygon tools | Polygon self-intersection as suggested here: How to sum up values of overlapping polygons in QGIS?

but in QGIS 3.0 I cannot choose an attribute table field as the identifier, only a layer. When I try to run Polygon self-intersection with the buffer layer as both the Polygons layer and the Identifier layer I get "TypeError: must be str, not bytes" and "UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 166: ordinal not in range(128)".

Is there another way of creating a raster from overlapping features within the same shapefile in QGIS or can I improve what I have already tried?

1 Answer 1

7

I was able to achieve this in QGIS 3.2 using the following work flow. There's a few steps involved and several processing algorithms all from the processing toolbox. For the layers produced in the intermediate steps below, I would recommend keeping them as temporary layers rather saving to file.

  1. Start with your layer of overlapping buffers.

  2. On this layer, run the Union algorithm from the processing toolbox. This will produce an output layer which contains multiple duplicate features.

  3. On this layer, run "Delete duplicate geometries". Now you should have a polygon layer with one feature for each of the overlapping sections of the original buffer layer. For some reason I ended up with invalid geometries at this point and had to run GRASS v.clean, so it may be advisable to do this also as an additional step.

  4. Create centroids from your cleaned union layer.

  5. Now run the algorithm "Join attributes by location (summary)". Use the centroids as the input layer and your original overlapping buffer layer as the join layer. Use "intersects" as the geometric predicate and for summaries to calculate select "count". This should produce a new point layer called "join layer" with a new field "value_count" which contains the number of overlapping segments from your buffer layer.

  6. We now need to join that attribute back to the union layer. For this just use the algorithm "Join attributes by location". For the input layer, use your cleaned union layer and the newly created "joined layer" as the join layer. For fields to add select "value count" and for join type select: "take attributes of first located feature (one to one).

  7. This should output a polygon layer also called "joined layer" which also has a field "value count" containing the number of overlapping buffer segments. I would recommend saving and renaming this layer. Here you can see this layer labelled and categorised with the "value count" field.

enter image description here

  1. Finally, rasterize this vector layer using the algorithm "Rasterize (vector to raster)" and use the "value count" field as the burn in value. Here is my resulting raster rendered in single band pseudocolour and coloured according to pixel value.

enter image description here

Your Answer

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

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