Bug report #5163

points in polygon: does not count points on boundaries

Added by alobo - over 12 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/QGIS
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

Description

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
are affected.
In the attached layer quadratsnbpoints
nbp: calculated in R
PNTCNT: calculated by qgis

pointsingrid.zip (327 KB) alobo -, 2012-03-12 03:40 AM

Associated revisions

Revision 9151fd58
Added by Alexander Bruy over 12 years ago

also count points that intersects polygon bounds (fix #5163)

Revision c936d031
Added by Alexander Bruy over 12 years ago

also count points that intersects polygon bounds (fix #5163)

History

#1 Updated by cfarmer - over 12 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):".

Carson

#2 Updated by Alexander Bruy over 12 years ago

  • Status changed from Open to Closed

#3 Updated by Alexander Bruy over 12 years ago

  • Resolution set to fixed

#4 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from 35 to Version 1.8.0

#5 Updated by Giovanni Manghi over 7 years ago

The "ftools" category is being removed from the tracker, changing the category of this ticket to "Processing/QGIS" to not leave the category orphaned.

Also available in: Atom PDF