4

I've seen a lot of questions about counting the number of points within a polygon but my question is I have 1 vector layer with polygons showing past landslides that have occurred and another 206 layers with each one of the layers representing a catchment. I need to count the number landslides that have occurred within each catchment. The only suggestion so far was to use "count points in polygon" but some landslide polygons span multiple catchments so if I convert the landslide polygons to points, I'm worried it would be much smaller than the actual polygon and wouldnt represent that the landslide spans multiple catchments.

Any tips?

enter image description here

3 Answers 3

5

Similar to the answer provided by @csk - I would:
1. Use the Merge vector layers tool to combine all the catchments into a single layer.
2. Use the Join attributes by location (summary) tool to count the OBJECTID (but could be any unique ID column) of the past landslides that intersects the catchments.

Join attributes by location tool

This will create a new catchments layer that contains a new column of data called OBJECTID_count. Any catchment without a landslide will be NULL.

Catchment layer with landslide count column

3

Also you can use aggregate expression in Field Calculator and create new field with interesection count, similarly to my answer on QGIS how to sum a certain vector field inside a polygon and populate a field in the polygon?. Instead of sum aggregate function use count like this:

aggregate(
layer:= 'landslide',
aggregate:='count',
expression:= $id ,
filter:=intersects($geometry, geometry(@parent))
)

Restult:

enter image description here

For more info check Aggregates QGIS documentation

0
  1. Combine the catchment areas into a single layer using the tool merge vector layers.
  2. Use the intersection tool to break up the landslides that intersect multiple catchments.
  3. Use the centroids tool to convert the intersected landslide layer into points.
  4. Use count points in polygon to count the points in each catchment polygon.

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.