In QGIS 3.16.2 (same on 3.16.0) on Win 10, I created a custom function get_color
to get a feature's color by layer name\id and feature ID as proposed in this answer by @Dror Bogin: https://gis.stackexchange.com/a/383753/88814
The expression was successfully created as it appears under custom expressions. However, I'm not able to get the function to run - using this data (project + layers). I try to define the color of the points as the color of the nearest polygon, setting the point's color to data driven override with this expression: get_color('Buildings',array_first(overlay_nearest('Buildings',$id)))
. This returns an error: Evaluation error: $id
. See my screenshot:
Using array_first(overlay_nearest('Buildings',$id))
however works fine, it returns a feature no. So $id
seems to be a problem together with the custom function get_color
in my case.
What is wrong - is there some setting I have to change? I restarted QGIS as well as Windows.
That the solution in principle works is demonstrated by @Dror Bogin who used the very same data as me (linked above) on his Win/QGIS 3.16.1 successfully, see his screenshot, where I get the error mentioned: