6

Using QGIS 2.10.1 I need to determine the distance from each feature in layer A to its nearest feature in layer(s) B or C or...

ESRI has this capability with their "Near" tool:

http://resources.arcgis.com/en/help/main/10.2/index.html#//00080000001q000000

Is there a QGIS equivalent?

I have

  • a point layer of 1269 boreholes
  • stream lines
  • lake polygons

I need to know, for each borehole, the single nearest distance to water (either stream or lake). In addition, I need to know whether that nearest water is stream or lake.

After completing the analysis, I envision the point layer's attribute table would contain 3 new fields:

  1. the nearest distance to water
  2. the layer (stream or lake) responsible for the nearest distance, and
  3. the stream or lake feature ID responsible for the nearest distance.
  • 2
    how about Vector menu > Analysis Tools > Distance Matrix – DPSSpatial Oct 28 '15 at 15:18
  • What are your features? Polygons, lines, points? I think most in-built QGIS functions deal with points to another feature type. In PostGIS, you could use st_shortestline coupled with the st_distance function to calculate distances between nearest features. – Joseph Oct 28 '15 at 15:25
  • 2
    Thanks for the quick responses. Unfortunately the Distance Matrix only works with point features, while the ESRI Near tool works with any combination of point, line and poly. – Stu Smith Oct 28 '15 at 18:56
  • 1
    Please clarify your requirements. While there might not be an exact equivalent of the tool, there might be something that fits your needs. – underdark Oct 28 '15 at 19:17
  • 2
    The NNJoin QGIS Plugin is what you are looking for. For each point, it finds the closest line. The resulting point layer will for each point contain the distance to the closest line and all of the attributes of that line. – Håvard Tveite Mar 25 '17 at 11:14
4

The NNJoin QGIS Plugin finds the closest line for each point. The resulting point layer will for each point contain the distance to the closest line and all of the attributes of that line.

NNJoin calculates the single nearest feature to each input feature. NNJoin works both between two different layers and within a single layer. To find the nearest distances between an input layer and multiple join layers, run the tool once for each join layer. Then join the resulting output layers to the input layer.

-Copied and paraphrased from comments made by @StuSmith and @HåvardTveite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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