# Average distance from point to polyline

This is a continuation of a question from GIS Transform polygon to equivalent circle, QGis. The point is inside the polyline, U, and I'm trying to calculate the average distance to the polyline Q.

However, I don't understand what we're integrating or how we obtain the average distance.

-
If you're trying to calculate the average distance to $Q$, why is it relevant whether the point is inside $U$? In fact, I don't think it even matters whether the point is inside $Q$. Also, you might want to explain what part of the answer you linked to you don't understand. –  joriki Mar 24 '11 at 11:23
Yes I see now that it doesn't matter whether the point is inside or outside Q. The part I don't understand about the linked answer is this- We are integrating b^2 = (x-t)^2 + y^2 between t=0 and t=1. This is the area under b if you extend b to the y axis. I don't see how this relates to the average distance between U and Q. –  user8656 Mar 24 '11 at 11:48
I'm still not sure I understand your question correctly; it would help if you were more explicit about what you're referring to. If I understand you correctly, it seems the piece you're missing is that the average of a continuously varying quantity is computed by integration, just like the average of a discretely varying quantity is computed by summation. This has little to do with areas; the area under a curve is only one possible interpretation of an integral. Specifically, the average of $f(x)$ over $[a,b]$ is $\int_a^b f(x)\mathrm{d}x/\int_a^b\mathrm{d}x$=$\int_a^b f(x)\mathrm{d}x/(b-a)$. –  joriki Mar 24 '11 at 12:21
I understand that integration is not just to find the area under a curve, and that here we can use integration it to find the average distance. I am unsure how to apply integration to find this average distance and cannot see how the integral given in the answer provides us with the average distance. The answer says to integrate b between t=0 and t=1- but I can't see how this gives us the average distance. –  user8656 Mar 24 '11 at 12:44
@Robertg: To see how the integration gives the average distance, imagine spacing $n$ points along one side and determining the average distance from $U$ to them. You would add up the distances from $U$ to each point and divide by $n$. When you pass to the limit, the sum of distances becomes $\int_a^b f(x)\mathrm{d}x$ and the number of them becomes $\int_a^b 1\mathrm{ d}x=b-a$ –  Ross Millikan Mar 24 '11 at 12:55