I am mapping the location of incidents of asthma using QGIS. I would like to count how many points are in census tracts to better understand the areas where asthma occurs most frequently. My map canvas presently displays the points of asthma from a CSV file, as well as census tract polygons from U.S. Census Bureau shapefiles.

I should be able to run the Points in Polygon function to help me. The function seems to work as I enter my CSV as the points, and the census tracts as the polygon. The function then returns a shapefile with an added column displaying "PNTCNT." Great so far. But, the attributes table indicates all zeros under the "PNTCNT" column. (This is obviously incorrect as I can plainly see that there are a many points in the census tract polygons.)

I tried saving the CSV file as a shapefile, and running the function again, but the result is the same. I'm at a loss.

Why is Points in Polygon giving me all zeros?

Here's the process I've used. Maybe someone can tell me where this is going wrong.

First, I add census tracts as shapefiles to my map. Second, I add a CSV that includes latitude and longitude for about 400 points. The CRS is set to WGS84 (EPSG:4326) for the points, and WGS84 / Pseudo Mercator (EPSG:3857) for the shapefile. Everything looks great on the map canvas.

Next, I select the points in polygon under the vector analysis tools. I select the shapefile under "input polygon vector layer." I select the CSV file under "input point vector layer." I input a file name and then hit okay. QGIS adds the new layer to my map canvas. However, when I open the attributes table the PNTCNT column reads all zeros. I have also tried the same process described above with the CRS set for both the shapefile and the CSV at WGS84 (EPSG:4326) (instead of using Pseudo Mercator for the shapefile).

  • 2
    Are you using the same coordinate system for both layers? – Hanne K Apr 22 '15 at 17:25
  • Could be a bug, which QGIS version and platform (eg. Windows, Linux etc) are you using? I can confirm that QGIS 2.6.1 for Windows, this tool works fine. – Joseph Apr 23 '15 at 10:00
  • I have the windows version. Here're my specs, copied from the "About" screen: QGIS version 2.4.0-Chugiak QGIS code revision 8fdd08a Compiled against Qt 4.8.5 Running against Qt 4.8.5 Compiled against GDAL/OGR 1.11.0 Running against GDAL/OGR 1.11.0 Compiled against GEOS 3.4.2-CAPI-1.8.2 Running against GEOS 3.4.2-CAPI-1.8.2 r3921 PostgreSQL Client Version 9.2.4 SpatiaLite Version 4.1.1 QWT Version 5.2.3 PROJ.4 Version 480 QScintilla2 Version 2.7.2 – George Apr 23 '15 at 13:39
  • Now that I have the most updated version of QGIS, I am really at a loss. Again, any help is appreciated. – George Apr 28 '15 at 14:15

Save both files as the same CRS. Load each of the files and then run points in polygon with the newly loaded files. The project on the fly is a visual aid. When running analysis it will use the CRS of the file.

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.