Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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: gis.stackexchange.com/a/11147/31 –  Jay Cummins Mar 27 '13 at 12:34

1 Answer 1

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

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.