4

In QGIS, how could I get the attribute of the nearest line to a polygon with an expression (or virtual layer)?

I wish to create a new field in the polygon layer(in this case the parcels) with the names of the streets (the line layer) that are nearest of them. I thought I could use aggregate but I didn't find any nearest function to go with it.

enter image description here

2
  • can you specify qgis version ?
    – Snaileater
    Commented Apr 5, 2021 at 14:35
  • Mine is 3.16.4-Hannover
    – Felippe M.
    Commented Apr 5, 2021 at 14:37

1 Answer 1

8

The following expression should work :

array_to_string(overlay_nearest('Streets', StreetNameField))

Adapt the expression to your data structure.

From QGIS 3.16 on, i think.

1
  • It worked perfectly, thank you very much!!
    – Felippe M.
    Commented Apr 5, 2021 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.