I got two files, a multi-polygon file with polygons and points (File 1) and a file with points only (File 2).
Our task is to fill the color of the points from File 2 with the respectively nearest polygon or point from File 1.
I use QGIS. I'm almost sure there is an expression or method to do just that!
We also got another line layer that shows the distance between the points and the respectively nearest point/polygon (File 1), so I could technically color it all manually, but I want to learn how to automate my workflow.
EDIT 1: @Babel’s answer does not work for me so far.
Here are the wrong symbols:
My two layers do not have the column "Id" but @osmId in the attribute table instead, but changing the "Id" with "@osmID" doesnt work either :/ https://ibb.co/020zD61
This is my command, which should be correct...: https://ibb.co/Fwy10Xk
I also tried to activate the current expression here, didnt work either: https://ibb.co/Y3bz13p
And lastly, I should add that that file 1 is a multi-polygon file with polygons as well as points...maybe theres the error?
Both definited by @osmId because there is no column "Id"
Now I want that the points from Layer / File 2 (Kindergarten_Karlsruhe) have the nearest colour either from the point from Layer/File 1 (Krankenhaeuser_Karlsruhe) (points) or from Layer/File 1 (Krankenhaueser_Karlsruhe) (polygons).
Layer 2 (Kindergarten_Karlsruhe) should receive the colour from either of those two geometries (polygons/points) from Layer 1 (Krankenhaeuser_Karlsruhe) which the respecitve kindergarten point is closest to.
Here you can see both Layers again: https://ibb.co/n3T03m2
Now, if type in the formula instead of "Id" "@osmId", there is an error messing appearing... see also: https://ibb.co/12jMZV2
This is correct, I have two (grouped) layers, both named Krankenhaeuser_Karlsruhe, once as polygon and once as points. I renamed both of them and set the colour settings from both again and tried to type in the command - still with an error!
Error Message: https://ibb.co/vYSGNxn