Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a polyline and a point on the polyline. I need to find the distance from the from point of the polyline to that point.

enter image description here

ICurve.QueryPoint method does the opposite thing. It gives a point based on given distance. In ICurve.QueryPointAndDistance method, specified point is a outside point and it gives shortest distance. I could not find any method that gives the distance I require. So I have tried something different. I took the polyline and split at specific point using IPolycurve.SplitAtPoint Method. I wanted to get my desired part's length from splitted part. But I guess it was a wrong procedure. I found a geometry collection and those geometry were not type of esriGeometryPolyline, they were type of esriGeometryPath. And the length of the path is not similar of my desired part's length. Can anybody give me some pointer about how to get the length?

share|improve this question
Would this help? The distance would be length of the polyline returned: – Jay Cummins Mar 27 '13 at 12:34
up vote 4 down vote accepted

Actually ICurve.QueryPointAndDistance method gives the distance along the polyline in DistanceAlongCurve variable.

double GetDistanceAt(IPoint point, IPolyline polyline)
    var outPnt = new PointClass() as IPoint;
    double distAlong = double.NaN;
    double distFrom = double.NaN;
    bool bRight = false;
    polyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, toPoint, false, outPnt, ref distAlong, ref distFrom, ref bRight);

    return distAlong;
share|improve this answer

Assuming the two points are on the the curve, you can use the QueryPointAndDistance on both points, get the difference and that is what you looking for.enter image description here

 Public Function distancebetweenTwoPoints(pPolyline As IPolyline, pPoint1 As IPoint, pPoint2 As IPoint) As Double


        Dim distancetoPoint1 As Double = 0
        Dim distancetoPoint2 As Double = 0
        'get the distance along curve for the first point 
        pPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, pPoint1, False, Nothing, distancetoPoint1, 0, False)
        'get the distance along curve for the second point 
        pPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, pPoint2, False, Nothing, distancetoPoint2, 0, False)
        'take the difference
        Return (Math.Abs(distancetoPoint2 - distancetoPoint1)) 'absolute that just in case point 1 is further to point 2 

    Catch ex As Exception
    End Try
End Function

More arcobjects stuff in my youtube channel here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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