I am trying to populate a point layer's field attribute with values from polygon features' attributes that contain point features.
The inverse is very simple:
aggregate(
layer:='point layer's name',
aggregate:='max',
expression:="point layer's field name",
filter:=intersects($geometry, geometry(@parent))
)
I need to do the exact opposite, get the attribute from the polygon feature and populate the points contained in said polygon.
I have tried contains
/intersects
/overlaps
/crosses
/touches
/within
to no avail.
I'm limited to doing this with the Field calculator expression or potentially PyQGIS, no SQL or DB Manager.
Best Answer
Firstly make sure that your layers spatially overlap i.e. the same location and the same CRS.
Secondly as it says in the documentation for
aggregate()
function:So, you can try either this:
or this:
Alternatively you can achieve the desired output with the
overlay_within()
andarray_max()
functions: