Bug report #15158

Points in Polygon Yields Zeros and Nulls

Added by Frank Donnelly over 8 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:Martin Dobias
Category:Processing/QGIS
Affected QGIS version:2.14.3 Regression?:
Operating System: Easy fix?:
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:23097

Description

Problem: the Points in Polygon Tool under the Vector menu - Analysis Tools returns zeros for some features and nulls for other features where points do no intersect polygons.

I'm using QGIS 2.14 Essen on a Windows 7 machine. I'm trying to count the number of points in one shapefile within the polygons of another shapefile. Both shapefiles share the same CRS, and both have clean geometries (verified using Vector - Geometry Tools - Check Geometry Validity). I'm just trying to count the points and save them in the default PNTCNT field in a new shapefile; I'm not doing any attribute summaries.

It correctly counts all the point features that fall within polygons. But for polygons that have no intersecting points, it returns a zero in some cases and a NULL in other cases. This behavior is inconsistent - looking at the output it isn't clear why some features receive zero and some get NULL. It should be one or the other. This creates problems when you attempt to query features using PNTCNT, as now you have to explicitly build queries to capture or exclude both zeros and nulls.

Tested this in QGIS 2.8 Wien, and the tool works fine. Zeros are returned for polygons where there are no points. NULLs are not returned.

point_poly_test.zip (226 KB) Frank Donnelly, 2016-06-28 08:41 AM

Associated revisions

Revision 46d40421
Added by Martin Dobias over 8 years ago

Return zero from "points in polygons" instead of both zero/null (fixes #15158)

History

#1 Updated by Martin Dobias over 8 years ago

  • Assignee set to Martin Dobias

Only affects 2.14 (release 2.16 has implementation in processing framework without this issue)

#2 Updated by Martin Dobias over 8 years ago

  • Status changed from Open to Closed

#3 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