2

So, I have a layer with an attribute contact, and I want to join these features with feature of the current geometry - so it selects all whose distance is less than 150. I currently have a list of all the features in QGIS drop down forms that shows list of all contacts, but I want to filter it to a specific radius.

  1. It's like creating a buffer from a current geometry (say point) and select all the features of another layer inside it.
  2. Or maybe we can use some distance formula with array aggregate to select all the features whose DISTANCE from current geometry is less than 150.

ALthough it seems easy, I still have used lot of my hours on it, and it seems my brain is stuck. So a fresh perspective could provide a real help.

Attribute Form View

Below is the form view, without filter. I want a filter that select features in 150m radius of current point geometry.

Form View

1 Answer 1

1

Not sure this will completely resolve your problem but in my case, I tried to show lines features from a layer that are below a certain distance value from a one specific polygon from another layer :

distance (
   closest_point (
      segments_to_lines (
         geometry (
            get_feature_by_id ('field',  @id_field>)
         )
      ),
      $geometry
   ), 
   $geometry
) < 150

If I understand correctly your expression, you don't set a distance limit.

2
  • Yeah, that as an expression works - but I want a filter that select values whose distance from current feature is WITHIN 150m. I have this expression array_foreach(aggregate('Sales', 'array_agg', $geometry), distance(@element, $geometry)) returns distance of all geometries. But I want values - not distances. In another way, first I selects all features of an attribute of 'Sales' layer. And then on this array use array_filter function to filter it by distance. I'm able to get the distance, but not the contacts. So, that's why cannot filter it. Mar 3, 2022 at 11:47
  • Maybe like this.. It's your question btw (SPOOKY COINCIDENCE). Mar 3, 2022 at 11:48

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.