How to determine length of a line sub-segment

Trying to find where to a point for an address on street segment that has multiple points. Is there a way to get the length of each section rather than the length of the full shape (polyline)

Hello @jonwinchester

There is not an inherent property to get the length of each segment, but it is a point collection. So you can iterate the points (from zero to numPoints) and calculate and accumulate the length of each segment.

Thanks. I had already started that approach. I am iterating through the points, creating a new shape for each pair and then querying the length from it until I get the distance I need.

Then (still working on this part) I am rotating the shape to a bearing of zero, so that I can easily (the math got a bit complicated otherwise) place the point a small distance off to the correct side, then rotating back to where it was. Then query the point for its coordinates to place the final point in the correct place on the street layer.

Does this sound like a valid approach?

Hello.

A function already exists for the first step in your process. A polyline shape has a method called LineInterpolatePoint, which will give you a point at the specified distance along the line.

The second part, I’m not so sure of. I think that you would want to evaluate the angle of just the segment containing your point. (getting that segment may require a walk-through of the segments). But having the angle of the segment, and using a little trigonometry (I always have to draw a picture), you would either add or subtract 90 degrees from the segment angle, depending upon which side of the street you want your point.

It would take me a little more time to come up with the nuts and bolts of the second part. But that’s how I would approach the problem.

Regards.

Thank you very much for the LineInterpolatePoint. That will help. And I also get out the pencil and start drawing triangle for the other. Thanks again.