It is not working as expected because one of the duplicate is closest to a point having a different name
Instead, it is possible to get multiple nearby points - with a max distance - and to count if there are duplicated names.
I would try r.fill.stats with a reasonably large value for the Distance threshold, depending on the size of your gaps. So let's say your maximum gap is 20 pixels wide, your Distance Threshold should be at least 10, better make that 11 to be on the safe side.
r.fill.stats Does not overwrite your original cell values, if you set this option, so your original ...
Using a point layer, you can not keep the boundaries at the same time within the same layer. But you can create two layers out of your raster: a point layer and a polygon layer.
For this to do, there are two convenient processing tools available:
Raster pixels to points
Raster pixels to polygons
For your goal, in this answer I suggest to use the polygons. ...
This is not possible with a simple query.
You can use a correlated subquery: for each crossing, look up the nearest road:
ORDER BY roads.geom <-> crossings.geom
) AS road_id
A lateral join works in the same way (the subquery is run for each row in ...