I have around 750 seperate shapefiles of species distribution data. For each species i want to calculate the number of atlas squares it occures in. Doing this for each object seperately seems a tedious job and i think there might be a faster way of doing this.

An example of the distribution map: Distribution of three species

So, Herniaria occurs in three atlas squares (or circles in this case). Hydrochaeris in 19 and Holcus in a whole lot. I have around 750 of these maps and i dont want to select each of these seperate, and go to the attribute table to calculate the number of rows (which is the number of atlas squares). I am trying for a while now, but cant find a way to do this for all the maps at once.

In the best scenario, the end product would be a list/CSV/XLS/TXT file with one column for the species and one column for the abundance (i.e. the number of atlas squares).

I hope this is possible.

  • You could mash (aka merge) all data into one shapefile, then dissolve by species, then calculate the area for each species, and since you know the size of a square, you then know how many squares you got.
    – Erik
    Dec 30 '19 at 10:57
  • Do you use PyQGIS ? Dec 30 '19 at 11:05
  • @VincentBré, I use the regular QGIS 3.6.3 NOOSA, i am not faniliar with Python unfortunately. Dec 30 '19 at 11:19
  • Ok but do you use PyQGIS (Python for QGIS), are you familiar with Python programmation ? Dec 30 '19 at 11:20
  • @Erik, unfortunately this does not work, because it calculates the area of the circle, which is not a perfect square kilometer. I choose to use circles instead of squares for aesthetic reasons, but squares would be better for your suggestion. Dec 30 '19 at 11:21

You need to create a column with aggregate values, for example count(1, "SPECIES"), the new column will have the total value for each species.

To make this easier, make all shapefiles with the same columns and merge them. Create the new quantity column, do the calculation and dissolve the shape by "SPECIES".

The result will be a shape with one line for each species found and the total value next to it. Just save as CSV or XLSX.

If merging the shapes is not an option, create a model to perform these steps and run it in batch.

  • This works, thanks a lot! Dec 30 '19 at 11:29

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.