I am trying to use the 'intersects' function within an 'if' condition. If a polygon in Layer A intersects a polygon in layer B, then the cell should display 'YES', otherwise 'No'.
However, I don't know how to properly call the Layer B in the field calculator. The expression I am working on looks like this :
if(intersects( $geometry,geometry('LayerB') ),"YES","NO")
Does anyone know how to put it correctly?
intersects
command will return a true/false response without the if statement, so you can drop that part. More importantly, though, theintersects
command requires that you have a specific geometry to test against. If you just want to check if it intersects ANY polygon in the second layer, you're going to need to do something a little more involved. Suggestion: use the Select by location tool to specify cross-layer intersections, then just create the new field and update selected features only.