I am using QGIS 2.8.3 but also have 3.4 whatever works better for this issue.

I have a bathymetry shapefile and a point layer. One of the columns of the bathymetry vector gives the maximum depth and I display the file by the different depth classes. Now I need to know how many of my points (point layer) are in which depth class. I tried to use the 'points in polygon tool' but it did not work, maybe cause there was no way to indicate which is the relevant column (depth max) cause the attribute table contains quite many columns.

  • this is well handled using SQL spatial, which can be done on shapefiles in QGIS, or using sqlite or ultimately postgis. but when you say "urgently", does this need to be figured out soon due to life or death, employment deadline, or educational project due date? Commented Aug 8, 2019 at 0:14
  • Indeed its a due date!
    – Tina
    Commented Aug 8, 2019 at 1:43

1 Answer 1


Using your QGIS 3.4 install you could use the field calculator to add a column to the bathymetry layer to show the number of points with each polygon. The expression to use would be like:

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

You would need to replace NameOfPointLayer with the correct layer name.

  • Option 1) Would I need to join the 2 files first? Or Option 2) only need to use the field calculator and with the expression, u mentioned and integrate the layer name of the point layer in it?
    – Tina
    Commented Aug 8, 2019 at 1:47
  • Option 2. No need to join the bathymetry layer to the point layer - the aggregate expression has all the info it needs.
    – M Bain
    Commented Aug 8, 2019 at 1:59
  • Instead of for bathymetry I used the approach you suggested for a substrate layer which is basically the same thing. I replaced 'NameOfPointLayer' with the relevant point layer...the processing took a while and the result is a new column which I named 'distance' but it only shows 0 in each row.
    – Tina
    Commented Aug 8, 2019 at 11:31

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.