I am attempting to map out, in a 10x10 km grid, the occurrence of unique plant species. I have used the "Points in Polygon" feature to count and map the unique points across the grid, however I have a new need. I have a .csv file with >100,000 observations of plants, and I want to count how many grid squares each plant species occupies, but only count it once for each grid square. So say I have 200 total 10x10 km grid squares I want to be able to say "Species A occupies 10 different 10x10 km grids, Species B 100 different... etc.

At the moment my map looks like the below:

enter image description here

I am using QGIS v. 3.0.3

  • You can do this interactively with a select by location, first restrict your species points to a particular species then select the grid squares by location then look at the count of selected features in your grid squares. This process is an ideal situation for scripting. You could also try intersecting the species with the grids then for each species count the unique instances of grid ID, a bit more advanced but still possible without scripting using plugins. – Michael Stimson Jun 29 '18 at 2:13
  • Thanks for the prompt response. I have over 500 different species, so yes, definitely a case for scripting and I probably don't have any other options. A bit above my knowledge base I'm afraid. Thanks again. – Joe Jun 29 '18 at 2:17

The first step is to join attributes by location see answer by Ursulka Siete Tutorial for QGIS, this will attribute your points with the matching polygons they fall within.

Next get tabular statistics for your points use a dissolve field of your species and a summary field of polygon FID (or other unique identifier field) and a summary type of count. This should give you a field listing each unique species and the number of polygons it appears in.

Note: I have not tested this plugin. I have ArcGIS and use Summary Statistics to perform similar operations. You might need to test a few statistical plugins before you get a result you can use.


As Luke pointed out, you can use Microsoft Excel (or similar spreadsheet program) to create a pivot table to summarize the information correlated by joining the attribute tables. The DBF component of a shapefile is a DBASE IV file which is readable by Excel (just don't save with Excel, it will break the shapefile) and probably a lot better at summarizing, charting and graphing aspatial data.

  • 1
    Another way to summarise is in QGIS "save as" the new output joined point layer to a odf/xlsx spreadsheet format then do a simple Pivot Table in Libre Office Calc or MS Excel. – user2856 Jun 29 '18 at 3:16
  • That works spectacularly well Luke, I've been immersed in ArcGIS for so long I'd forgotten about using Excel (or similar) to pivot table summarize. Thanks for reminding me. – Michael Stimson Jun 29 '18 at 4:10
  • Hi all. This worked perfectly. I joined attributes by location in QGIS, the exported the layer into Excel and analysed with a pivot table. – Joe Jul 12 '18 at 0:53

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.