I have a vector point layer with an attribute Customer with boolean values true and false. I want to aggregate this data by polygons, such that for a given polygon, it shows that Customer is XX% true and YY% false. I can't achieve this with join attributes by location (summary); I can only get Customer_COUNT from this.

Attached an example for reference -- I basically want to get the % blue and green points within a polygon.


3 Answers 3


You can use field calculator with overlay_contains() (or eventually overlay_intersects() depending on your needs) expression on your polygons for this. To get the count for each category simply set a filter to your needs, for example:


respectively for the other category


Then calculate the percentage from these. So all in one:


Just replace points with the name of your points layer and "cat"=1 with your field containing the category and the desired value of this category.


Try this expression in the polygon layer:

    overlay_contains('point layer name/id', "Customer"), -- replace here with your values
        100 / array_length(@values),
            '%1% true, %2% false', -- output will look like ##% true, ##% false.
            @total * array_count(@values, true), -- quote true if your field in the point layer is not boolean or is string
            @total * array_count(@values, false) -- same as above

you can control the format of the result modifying this line ('%1% true, %2% false') as explained here, for example: 'true: %1%, false: %2%' will look like true: ##%, false: ##%.


You can use "Count Features in Features by Category" from ProcessX Plug-In for this usecase.

Choose your polygons as Source-Layer, your points as Overlay-Layer, add the field containing your Customer as Category-Expression. As desired output structure I assume you want to choose Create a field for each category. Adjust the other settings if needed as well.

enter image description here

This will produce a copy of your polygon layer with two new fields added: Customer_True and Customer_False. Then use field calculator to calculate the percentage out of these.

Disclaimer: I am the author of that Plug-In.

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.