2

I am looking for an expression in QGIS that allows me to select polygon features (layer 1, red polygons), that intersect more than 50 percent of the buffer ring around a point feature of another layer (layer 2, green point).

The buffer does not touch the buffered feature. It has a certain distance to it. Ideally I would not need to create a new layer for this.

I want to use this expression for the field calculator. Combined with CASE WHEN THEN, the polygons in layer 1 that intersect more than 50 percent of the buffer ring will get the value "good".

enter image description here

Tom Brennan
6,24612 silver badges32 bronze badges
asked May 15, 2023 at 9:21

1 Answer 1

2

Something along the lines of the following may achieve your objective.

You haven't specified how the buffer ring is defined. I have arbitrarily given it an outer radius of 1000 and inner radius of 500, with 50 segments.

Also, I've just assumed that the green point is feature ID = 1 in (which you will need to replace with your layer ID).

In short:

  • Create an outer ring and inner ring based on the green point
  • Take the difference of those to create your buffer ring
  • Take the intersection of the buffer ring and each polygon
  • Calculate the area of intersection
  • Divide this by the total area of each polygon
  • Check if greater than 0.5
area(
 intersection(
 difference(
 buffer(
 geometry(
 get_feature_by_id(<layer2>,1)
 ),1000,50
 ),
 buffer(
 geometry(
 get_feature_by_id(<layer2>,1)
 ),500,50
 )
 ),$geometry
 )
) / $area > 0.5
answered May 15, 2023 at 10:41
6
  • Thanks a lot. I specify: The buffer shoud be around all features (green points) in layer 2, other asumptions are perfect. I adopted your expression to my case: CASE WHEN area(intersection( difference( buffer(geometry('layer 2'),1000,50), buffer(geometry('layer 2'),500,50)),$geometry) ) / $area > 0.5 THEN 'medium' WHEN area(intersection( difference(buffer(geometry('layer 2'),499,50), buffer(geometry('layer 2'),1,50)),$geometry) ) / $area > 0.5 THEN 'good' ELSE 'bad' END I receive the error message: cannot convert to feature. U know why? Commented May 15, 2023 at 15:15
  • 1
    The geometry function in Expression Builder takes a feature argument, not a layer - hence the error message: "cannot convert to feature" Commented May 15, 2023 at 22:05
  • 1
    If you want to deal with multiple buffer rings, you will need to define your problem more carefully. For example, what happens if the rings overlap? And what if a polygon overlaps 30% of one buffer ring, and 40% of another? Is that good or bad? Commented May 15, 2023 at 22:16
  • 1
    Geometry in expression builder can't refer to a layer. However, there are sometimes tricks that can be used to sum up results across multiple features of a layer. Remember to go back and edit the original question with clarifications (and possibly extra screenshots). Commented May 17, 2023 at 2:04
  • 1
    You may in fact be better off asking your more detailed requirements as a separate question, referencing this one. Commented May 17, 2023 at 2:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.