0

I would like to know if there is a way to select the part of a layer that is located at the left (or at the west) of another layer. I thought it would work with select by location, but I don't know how to do it.

  • Please add a picture of the layers. Such task can range from very simple to extremely hard depending on the complexity of the shape(s) – JGH May 22 at 16:37
1

You can do the requested task using not Select by location but Select by expression.

In the image below you can see one example of the necessary expression that selects all the features that have an X coordinate smaller than the X_min (minimum X coordinate) of the polygon.

This selects all the features on the left side. This is the expression:

--features on the left
 $x < x_min(geometry(get_feature('polygon','id',1) ))

If you want to select all the feature on the right side just change the symbol < with > and x_min with x_max.

enter image description here

NB: This expression work with points. If you want to select lines or polygons, using the same expression, the X coordinate of the selectable layer will be the centroid of the geometry.

To change from the X centroid to the extreme coordinate, you must change the $X with x_min($geometry) or x_min($geometry) according to the side you want to select.

Example with lines:

  x_max($geometry) < x_min(geometry(get_feature('polygon','id',1) ))
| improve this answer | |
  • Oh thanks ! I will try this ! – Andréanne May 26 at 16:16
  • 1
    If you are happy with the answer, please vote it. This help other people to understand if the answer offers a good solution. – Val P May 30 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.