Bug report #15158
Points in Polygon Yields Zeros and Nulls
|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|
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.