QGIS's “Points in Polygon” counts zero in every census tract
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).
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.