3

I'm trying to create a new field in my attribute table that can assign a value to the polygon depending on how many layers of my buffers it intersects.

So i have a base layer called "properties" and other layers from which i have created different buffers "transport" "green areas" "city center"

In the "properties" layer I want to add a new field to the attribute table assigning a different value depending how many layers (buffers) the polygon intersects.

For example:

If the polygons in "properties" intersects or is contained just "transport" = 1

If the polygons in "properties" intersects or is contained "transport" and "green areas" = 2

If the polygons in "properties" intersects or is contained "Transport", "green areas" and "city center" = 3

If the polygons in "properties" does not intersect any buffer= 0

Any idea if this can be done? And if yes how can I do it? im quite new to QGIS and im still exploring and learning how all the expressions work.

1 Answer 1

1

Use this expression in the properties layer to calculate the count of intersecting layers.

array_length(
    array:=array_filter(
        -- list of layer names to evaluate if are intersecting "properties layer
        array:=array(
            'transport',
            'green areas',
            'city center'
        ),
        expression:=overlay_intersects(
            layer:=@element
        )
    )
)

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.