2

I have around 750 separate shapefiles of species distribution data.

For each species I want to calculate the number of atlas squares it occurs in. Doing this for each object separately 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 don't want to select each of these separately, and go to the attribute table to calculate the number of rows (which is the number of atlas squares). I have been trying for a while now, but can't 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.

5
  • 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
    Commented Dec 30, 2019 at 10:57
  • Do you use PyQGIS ? Commented Dec 30, 2019 at 11:05
  • @VincentBré, I use the regular QGIS 3.6.3 NOOSA, i am not faniliar with Python unfortunately. Commented Dec 30, 2019 at 11:19
  • Ok but do you use PyQGIS (Python for QGIS), are you familiar with Python programmation ? Commented Dec 30, 2019 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. Commented Dec 30, 2019 at 11:21

1 Answer 1

3

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.

1
  • This works, thanks a lot! Commented Dec 30, 2019 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.