Let's say I have the scenario where
- Polygons A and B intersect polygon c
- There are also polygons X,Y and Z which do not intersect c.
- Polygon C has an attribute value 'Priority' which I need the value propagated onto intersecting polygons (that is, onto Poly A and B).
All the data is in a single layer in a geopackage table.
I have no drama's selecting polygons A and B, I'm looking at trying to update them using the Field Calculator and an expression. But I'm having an absolute brain fade as to how to refer to self.
That is - how do I find intersecting polygons on the layer that I'm already using and get their attribute values?
My logic is to write a function and apply it to a selection set (which I would select outside of the function). So far I have the following:
def get_value_func(): # Firstly, get the set of polys I want to grab values for. Lets just use the 'c' poly for now geometry_col = collect($geometry, , filter:="layer_name" = 'c') #then lets test if the current geometry intersects anything within the geometry collection if(intersect($geometry, geometry_col), update_val = <THIS IS THE BIT IM NOT SURE ABOUT>)) return update_val
Its possible I'm overcomplicating things and am happy to hear other ideas about how to achieve this. Maybe collection isn't the right data structure to be using.