2

In QGIS 3.0.1, the vector analysis algorithm 'Count points in polygon' is returning wrong counts for some polygons. The counts returned for all of the polygons which do not contain any points appear to be correct - i.e. they are all 0. The counts returned for many, but not all, of the polygons that do contain points are greater than the actual counts (based on my own visual inspection of the points layer rendered on top of the polygons layer) of the points contained in each of the polygons.

I've zoomed in to all of the points contained in the polygon (highlighted in red in the image) to ensure that I count all points, and there are only 16 points. The count indicated by the 'NUMPOINTS' attribute in the 'Identify Results' pane in the bottom right is 34.example of wrong count of points in polygon

  • And you are sure there are no overlapping points? How many does it indicate as selected, if you select all of those? – HeikkiVesanto Mar 27 '18 at 14:05
  • @HeikkiVesanto Yes, I am sure there are no overlapping points, but when I 'Select Features by Freehand', QGIS indicates (in the bottom left of the screen) that 34 features are selected. So it appears that the number of features selected is not being correctly counted and/or displayed. From the results I see at issues.qgis.org/projects/qgis/issues after filtering for 'count' in the subject, it looks as though this issue has already been reported...? – james Mar 27 '18 at 15:20
  • I don't see any bug reports that respond correspond with the issue you are having. I highly suspect that you have overlapping points. What is the data? Did you create it? – HeikkiVesanto Mar 27 '18 at 15:42
  • @HeikkiVesanto After further inspection of the points layer, it appears that you are correct - there are often multiple features with the exact same location. I'm embarrassed to have not discovered this on my own, but, in any case, thank you! – james Mar 27 '18 at 18:31
  • No problem. Happens to the best of us. It is hard to notice as selected features are no bigger than not selected ones, so they may be hidden underneath. – HeikkiVesanto Mar 28 '18 at 8:57
2

I suspect there are overlapping features on your layer, that have the exact same location.

The easiest way to find out is to select the features visible and check the attribute table for the selected features.

Alternatively you can set the transparency to around 50%, and locations with more than one point will be darker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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