# Summing attribute from overlapping polygons in QGIS

I have a number of bus stops (green points) and a layer of population data (square polygons) containing information on the number of households.

I want to know how many households are within the 500m buffer of the points.

How do I sum the attribute (number of households) to a new value for each point?

• Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works. Thanks.
– PolyGeo
Aug 9, 2019 at 8:37
• It looks like you will need to split your population squares by the buffer outline and then use the relative areas to proportion the population. If so look at the Processing toolbox's overlay tools. If you have 3.8 you could also look at the Overlap analysis tool in the Vector analysis section and Join attributes by location summary tool in vector general.
– John
Aug 9, 2019 at 12:32

Here are a couple of ways to sum up the total value of intersecting polygons.

• Install the refFunctions plugin, and use the Field Calculator to add a field to the buffer layer with this expression:

``````intersecting_geom_sum('population_data_layer','number_of_households')
``````
• Use the Field Calculator to add a field to the buffer layer with this expression:

`````` aggregate( 'population_data_layer', 'sum', "number_of_households", intersects(\$geometry,geometry(@parent)))
``````

Notes:

• This method will lead to over-counting, because households in squares that just barely touch the buffer will be counted as though all of them are inside the buffer.
• You can under-count by using `within` or `within_geom_sum` instead of `intersects` or `intersecting_geom_sum`.
• You could split the difference by doing both calculations and taking the average.
• Or, as johns pointed out in the comments section, you can re-calculate the value based on the proportion of the area of each square that intersects the buffer. This assumes that the households in each square are evenly distributed throughout the square. It's probably a better approximation of reality than the approaches above. See this and related questions for how to calculate proportional area:

• Tried both and failed. Is this solution still doable on the last version of QGIS 3.20.2? Sep 13, 2021 at 12:37
• @Arthur I don't know. I haven't used QGIS in some time. My advice would be to read the guidance documentation for the `intersecting_geom_sum` and `aggregate` functions. The `aggregate` functions were relatively new at the time I wrote this answer, so they may have changed syntax. Or perhaps they changed the spelling on the other function, eg perhaps they made it `intersecting_geometry_sum` instead. If it's only a minor syntax change, you should be able to fix it by re-creating these expressions using the built-in help in the Field Calculator.
– csk
Sep 20, 2021 at 10:26

My solution was the following

• Join attributes by location (summary)
• Where the buffers are the input layer and the demographic data the join layer
• Set on interct
• Fields to summarise -> the number of households
• summaries to calculate -> sum

Now the buffers have a new attribute with the total of households.

• Join attributes by field value can be used afterwards to copy these attributes to the points