Is there a plugin available that will calculate this?


The red polyline is the average distance of the point to the black polyline. The red polyline is what I want to display. Alternatively, is there something which would calculate the radius of the circle so I can use a buffer?

enter image description here

  • 1
    Could you illustrate what you mean by "average" distance? – underdark Mar 30 '11 at 12:41
  • @underdark; EDIT 1 added with image – Robertg Mar 30 '11 at 14:54
  • Are your polylines always boundaries of polygons that contain the point in question? – underdark Mar 30 '11 at 14:56
  • @underdark It doesn't matter whether the polygon is closed or not, nor does it matter where the "node" is located. – whuber Mar 30 '11 at 14:58
  • @underdark The polygons have been created using the Voronoi polygons tools, and the point is one of the nodes. So in this case the node is always within the polygon/polyline. – Robertg Mar 30 '11 at 14:59

Using QGIS and GRASS, this should be doable:

  1. Split the line using v.segment
  2. Add the point you want to calculate avg distance for
  3. Use QGIS "Distance Matrix"
  4. The last column in the matrix should contain all distances. You just need to calculate the mean.

I'm sure there is a GRASS alternative to distance matrix (v.distance?). As far as I know, there is no equivalent to v.segment in QGIS yet.

  • +1 Thank you for translating this into a QGIS workflow. It's a pity you need other software for the splitting into points, though. In fact, in addition to GRASS you also need some script or software to generate the distance offsets along the polyline, as far as I can tell. But the workflow should succeed. – whuber Mar 30 '11 at 19:52
  • 1
    v.segment is now available though QGIS Processing. – Håvard Tveite Sep 30 '14 at 15:36

It's unlikely QGIS (or any software) has implemented the exact formulas provided in the antecedent thread, but one could sample a polyline at regular intervals, compute the distances between the sample points and the "node," and average them: these are common operations available in many GISes. (This is a Riemann Sum, or rectangular, approximation to the integral. Improved approximations, such as with the Trapezoidal Rule or Simpson's Rule, can be implemented similarly. Correct application of Simpson's Rule would require estimating the average distances separately over each segment of the polyline and then forming the segment-length-weighted average of those results.)


AV 3 screenshot

This screenshot (using ArcView 3, an old simple GIS :-) illustrates the procedure. A 10 km feature in a road layer (barely visible in black) has been sampled at 100 m intervals (shown in darker cyan) beginning at a random location. Another point layer containing a single point (shown as a cross) has been spatially joined to the sample points. One result of the join is to compute a [distance] value to each of the sample points, shown in the table at left. A statistics dialog displays the mean distance (of 3503 meters), shown highlighted. A circle of that radius (red) was manually added based on that information.


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.