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 hope you can help me with that one. I'm using ArcObjects with C# trying to rotate only one part of a polyline at a vertex or distance along the polyline. The polyline is zAware and has values at regular spacing.

The only successful way I've found so far is splitting the polyline at the vertex first, then using ITransform2D.Rotate to rotate one of the resulting features by a specified angle, and finally merging both features again afterwards.

All this takes a long time and I had many lines to code. Unfortunately I haven't been able to find a quicker solution. But if any of you know about a more clever way, please tell me!

Thank you very much!

Pivot polyline, before and after

share|improve this question
Does "only one part" mean that the polyline is already a multi-part polygon? – Kirk Kuykendall Apr 12 '13 at 13:41
Hi Kirk! No, what I meant was that I don't want to rotate the polyline as a whole but bend part of it by an angle. I forgot to mention that the polyline is zAware and has values at a regular spacing. – Hubert Apr 12 '13 at 14:22
Ah, ok, a before and after picture of what you want to do would be very helpful. Sketch it out in arcmap, then File>Export Map, then add the resulting png's to the post. – Kirk Kuykendall Apr 12 '13 at 14:51
I tried by editing my post, but for whatever reason the image doesn't show. Well, I'm trying to describe it then. Imagine I have a straight line of 1000 m. At a distance of 800 m from the FromPoint I want the remaining 200 m of the line to bend clockwise by an angle of x. I end up with a line that is not straight anymore, but "turns" right at 800 m. – Hubert Apr 12 '13 at 15:41
I saw, it, and then didn't see it after you removed it. Sometimes a firewall can block the imgurl. I put it back in. And now can see it. – Kirk Kuykendall Apr 12 '13 at 15:45
up vote 4 down vote accepted

AFAIK, the most simplest and fastest way is edit geometry with vertex level. Polyline is collection of Points and you can edit points and replace it. In this case, rotate each vertex with pivot anchor point, and interpolate new z value. then replace original points to these rotated points. So the code will be like this,

//sample: pivot index is 3, radian is 45degree
int pivotIndex = 3;
double radian = 0.785;

IPointCollection4 pPointColl = pPolyline as IPointCollection4;
IPoint pPivotPoint = pPointColl.get_Point(pivotIndex);// PivotPoint Point
int pointCount = pPointColl.PointCount;

List<IPoint> replacePointList = new List<IPoint>();

//Loop next to the pivot point to the end of point
for (int i = pivotIndex + 1; i < pointCount; i++) {

    IPoint pPoint = pPointColl.get_Point(i);// vertex Point to rotate
    ITransform2D pTrans2D = pPoint as ITransform2D;
    //Rotate vertex point with Pivot Point Anchor
    pTrans2D.Rotate(pPivotPoint, radian);

    //interpolate z value from raster..
    pPoint.Z = <new value>;


//Replace original points to rotated points
IPoint[] replacePoints = replacePointList.ToArray();
IGeometryBridge pBridge = new GeometryEnvironmentClass();
pBridge.ReplacePoints(pPointColl, pivotIndex + 1, replacePoints.Length, ref replacePoints);

By the way, you can reuse GeometryBridge object , so you don't need to create instance every time. Hope this will help you.

share|improve this answer
Thanks for the tip! As my lines are zAware and have values/vertices at regular spacing I would have to rotate any vertex between the pivot point and the ToPoint of the polyline. Would you use IPointCollection.EnumVertices to do so? – Hubert Apr 13 '13 at 15:16
Hi, sorry I was overlooked. But in this case, you are rotating in 2D space, not 3D. So, you don't need to take care about zAware. Ok I'll fix code to correspond multi vertices, but first do you have to consider about multi-part Polyline? If you don't need to do so, I guess IPointCollection.EnumVertices is too heavy to use. – Darksanta Apr 14 '13 at 3:54
Correct, I'm only rotating in 2D. But ideally, each vertex is updated with the underlying elevation value after it is moved. Contrary to the image above, there might be cases where I need to bend the polyline part between the pivot point and the FromPoint, rather than the ToPoint. – Hubert Apr 14 '13 at 17:22
Hi, I edited my answer. Sorry but I didn't have much time to test code now. Anyway, this code is corresponding to multi vertices and also change z value. Please let me know if you have some question. – Darksanta Apr 15 '13 at 16:29
Thanks for the code! It pretty much looks like what I had written according to your earlier snippet. Before the actual rotation I'm using pPolycurve.SplitAtPoint to introduce a new vertex which will function as the pivot point. As I don't know the index of the pivot point at that stage, I cast the polyline to a point collection first. Then I loop through the points having a if statement that checks on x and y. This way I find out when to start rotating the vertices. A combination of HitTest, Math.Sign and a flag answers the question which "part" of the polyline has to be bent (From or To). – Hubert Apr 16 '13 at 8:15

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.