2

this seems like it should be a simple task but so far I've not had any luck. I have a points shapefile (showing where manholes are on public roads), and a polygon shapefile showing where building foot prints are. I want to take the attributes of the closest building footprint polygon to a manhole point - using a nearest distance algorithm. Is there any simple way to achieve this in QGIS?

1

2 Answers 2

3

My suggestion is refFunctions plugin, which will add geomnearest() function to your Field Calculator.

Then open the attribute table of your manhole point layer and create a new field with an expression geomnearest('buildings', 'owner') (if the layer name of your buildings is buildings and you want to extract its owner field. (Please note the single quotation marks, not double).

enter image description here

It will take the owner field and add the information to your manhole point layer.

enter image description here

2
  • Thanks Kazuhito! Your steps solved the issue perfectly. Appreciate the help!!!
    – randomkiwi
    Commented Jun 6, 2018 at 22:56
  • refFunctions was integrated into QGIS 3.16 in 2020. As of QGIS 3.34 (2024) the functionality's accessed through overlay_*() in the field calculator.
    – Todd West
    Commented May 9 at 21:20
1

If you want a simple tool to do the task, you could consider the NNJoin plugin. For each feature in the input layer (point, line, polygon), it finds the closest feature in the join layer (point, line, polygon). The resulting layer will for each input feature contain the distance to the closest join feature in addition to all the attributes of the input feature and the join feature.

1
  • Note for subsequent readers: NNJoin hasn't been updated since September 2019. As of QGIS 3.34.6 (May 2024), Vector -> NNJoin -> NNJoin fails with TypeError: setValue(self, value: int): argument 1 has unexpected type 'float'.
    – Todd West
    Commented May 9 at 20:59

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.