I look for an expression in QGIS field calculator, that calculates the distance between the centroid (red dot) of polygones (red polygones) of layer 1 and the nearest (point-) feature of layer 2 (green dot). (I don't want the centroid as a seperate layer, it should be calculated "on the flight". The calculated distance should be a new field in layer 1 attribute table)
I guess the necessary functions are "distance" and "closest_point" and "get_feature". I tried this expression:
distance(centroid($geometry), closest_point($geometry, get_feature( 'layer 2'))
but receive the notification that the function "get_feature" needs 2-3 arguments, but there are 3.
What would be the right expression? Thanks in advance