I would like to have an example on how to use the Intersects function in the Field Calculator of QGIS.
Basically, I want to know which feature from a polylines layer intersects a polygons layer and store the result in an attribute. (0 = not intersecting, 1 = Intersecting).
I'm aware of the geoprocessing tools "Clip" or "Intersect", but is it possible in the Field calculator ?
Best Answer
This is not possible in field calculator. The intersect function in the field calculator does not work with two layers. What you can do is calculate intersections with specific geometries, e.g.
For more on these spatial operators check http://docs.qgis.org/latest/en/docs/user_manual/working_with_vector/expression.html#geometry-functions
Instead, use the Spatial query plugin to first select all features that intersect the polygon layer. Then use field calculator and only update selected features to set the intersection attribute to 1.