5

This is a follow up question to this question.

I have in QGIS v3.22 two layers: polygon hex layer and points layer.

I want to count all the points that overlap with the polygon layer and display the sum of the points. This dynamic view must be generated in polygon layer Geometry Generator and the desired result must visually correspond to this image enter image description here

0

1 Answer 1

8

label expression

  1. Insert this code into Value box in the Layer Styling tab:
aggregate(
  layer:='Random points',
  aggregate:='count',
  expression:=1,
  filter:=intersects($geometry, geometry(@parent))
)
  1. Replace Random points with your points layer name.
  2. All data must be in one (same) projection.
  3. After you add a new point you have to save the edits and update map window (for example move extent).

Result (gif animation):

result gif

9
  • it counts, but value is "0"
    – Rii Pii
    Sep 16, 2022 at 12:10
  • yes it is "fid" and I changed layer name correctly ... it shows 0 - I see number in the middle of hex, bud it is wrong number. I double cheked this formula also in help
    – Rii Pii
    Sep 16, 2022 at 12:51
  • sorry I can't share data, is there any alternative solution? HEX layer is dublicate layer of original layer. I can share only picture.
    – Rii Pii
    Sep 16, 2022 at 13:04
  • 3
    it should also work with expression:='1', no need to worry about an existing or populated field
    – JGH
    Sep 16, 2022 at 14:03
  • 3
    @RiiPii make sure both layers have the same projection.
    – JGH
    Sep 16, 2022 at 14:06

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.