Maps with a lot of dots are cool, but sometimes you’d like to count the number of things in a certain geographic area - maybe subway entrances per zip code, murders per neighborhood, etc.
This is a relatively common practice, and relatively easy. Sometimes you need a lot of processing power to get it done, but so it goes.
NOTE: So, this one works, but most people apparently use
Vector > Data Management Tools > Join Attributes By Location! Points in Polygon is more useful when you have a lot of overlapping polygons.
I’ve used a CSV of after-school programs for NYC and a shapefile of school districts. We’re going to be adding a column to count them up.
Make sure that your features overlap! If you don’t see any points in the same area as your shape, something probably went wrong with your CRS.
Now use the top menu, and select
Vector > Analysis Tools > Points In Polygon
Now let’s complete the Point in Polygon fields
PNTCNT- for some terrible reason there’s a restriction on the length of the field name.
Layersonce it’s complete.
When you’re combining a CSV and a shapefile, QGIS likes to complain about the CRS not matching even when it does match. If you get this error, you can probably ignore it.
Right-click your brand-new layer, then select Open Attribute Table.
This will show you that your new shapefile contains not only the columns from before, along with any other columns it contains.
Maybe you’d like to learn how to color your map based on a column or aggregate some column of the points across the shapes?