I have a layer (called here 'layer_top') made of multiple polygons (in orange in the picture). Each polygon of the 'layer_top' overlaps with polygons of other different layers (called here 1,2,3,...). Each of these layers, within the 'layer_top', has a column with a score value (like in the picture). I would like to get the sum of the scores of all polygons of the layers 1,2,3, ... contained in each polygon of the layer_top.
I have searched for a solution in this forum and tried to join attributes by location (including summary), but the result is not what I want.

Asked
Active
Viewed 223 times
5
AUS85
- 446
- 3
- 12
2 Answers
4
Use QGIS expressions with overlay_contains(). Use this expression where score1-3 are the names of the attribute you want to get the sum from:
array_sum (overlay_contains ('layer1', score1)) +
array_sum (overlay_contains ('layer2', score2)) +
array_sum (overlay_contains ('layer3', score3))
Babel
- 71,072
- 14
- 78
- 208
-
Thank you. Where do you use that function? in the field calculator of the 'layer_top'? – AUS85 Dec 05 '22 at 18:40
-
-
It says invalid expression. I think this is also time-consuming. What if I create a raster above the layers 1,2,3... and I calculate the highest score under each pixel? I mean I want to assign to each pixel the score of the layer below it that has the maximum value. How can I do that eventually? – AUS85 Dec 06 '22 at 11:32
0
I have found a solution for this question: transform all layers in raster and then sum the values with r.series of GRASS. Easy!
AUS85
- 446
- 3
- 12
array_foreach()function to avoid repeating the same part over and over again. If interested, please provide information about the number of layers, their names and name of attributes. – Babel Dec 05 '22 at 16:31