I am trying to filter an attribute table in QGIS 3.22 using 'Advanced Filter (Expression)' so that the filtered features shown are only those that intersect with a value of an attribute in another layer. The layer I want to filter is a shapefile showing owners of areas of land. The layer I want to filter it by is a shape file of land uses. So, for example, the land use file contains a value 'Quarry'. I want then to filter the land owners table so that it only shows the owners that intersect with the 'Quarry' value in the land use shapefile. This then helps me to see if the land owner is likely to be a quarrying company.

I don't want to run a spatial join, both because this will take 2 days to run and because it won't help me as much as being able to visually assess each intersect.

I have tried using the expression intersects($geometry,(get_feature( 'Land_use_ layer', 'Land_use_field', 'land_use_value'))) but it comes up with an error 'Eval Error: Cannot convert to geometry' and I'm not sure why. Am I close?!

1 Answer 1


Both parameters of intersects have to be a geometry. get_feature returns feature itself. You need geometry function to get feature's geometry.

                   'Quarry' ) ) )

This solution is for Query Builder (right-click layer > Filter...)

enter image description here

  • Thanks. That does work but I think it only shows the first feature in the land use layer? As I believe get_feature 'Returns the first feature of a layer matching a given attribute value.' How can I filter for all features that intersect with 'Quarry' in the other layer? Commented Feb 12, 2022 at 0:08
  • This solution is for Query Builder (right-click layer > Filter...) Commented Feb 12, 2022 at 0:58
  • Unfortunately that still doesnt work in Query builder. I get "An error occurred when executing the query. The data provider said: OGR[3] error 1: SQL Expression Parsing Error: syntax error, unexpected $undefined. Occurred around : intersects($geometry, geometry(get_feature" Commented Feb 12, 2022 at 11:00
  • Is another option to use the 'Overlay_intersects' function? I tried this and it accepted the function but it froze my machine! Commented Feb 12, 2022 at 11:47
  • Using expression may cause freezing QGIS if you have a huge dataset. Because every time the expression runs, it checks if the current feature's geometry intersects all geometries in the other layer. Try to run the expression after using "Create Spatial Index" tool for both layers. Commented Feb 12, 2022 at 11:59

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.