Bug report #5163
points in polygon: does not count points on boundaries
|Affected QGIS version:||1.7.4||Regression?:|
|Operating System:||ubuntu 10.04||Easy fix?:|
|Pull Request or Patch supplied:||No||Resolution:||fixed|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||14915|
Results from points in polygon
are different than those obtained from R.
Results from qgis are always equal to or lower than
the number calculated by R.
Visual inspection indicates that only points on polygon boundaries
In the attached layer quadratsnbpoints
nbp: calculated in R
PNTCNT: calculated by qgis
#1 Updated by cfarmer - almost 8 years ago
This is because it isn't programmed to test for intersections :-p The tool checks for containment: It uses QgsGeometry.contains, rather than QgsGeometry.intersects. I suppose intersections would also be perfectly valid, but it is called 'points in polygon' :-p
I don't have a development environment set up at the moment, so can't fix/implement this right away - so will leave this ticket open. Any other developers want a quick fix? Just change line 143 in doPointsInPolygon from " if inGeom.contains(tmpGeom.asPoint()):" to " if inGeom.intersects(tmpGeom):".