Tuesday, 9 October 2018

arcmap - Polygon points to Polyline


I am trying to create a polyline from the points that I query from a polygon. I have a polygon, and I am getting its edges, casting them to segments, and then use QueryNormal to get the mid point for that edge. I get 2 different points from 2 edges, I want to create a curve from those 2 points, not a straight line, but follow the polygon path from one point to another. the pictures below explain things better. I tried using the topological operator and cut but thats not doing what I want, I tried using the polygon.Split() but also that does not give me what I want. Is it possible to split a polygon based on points?


Here is what I want, I have a polygon and I want to use the points to create the curve


New Edits:- After being able to get the subcurve using the 2 input point distances, it is always giving me the longest part of the polyCurve, here is apicture of what its doing, where I want the short path as per the picture above. enter image description here




Answer



I solved the problem, by getting the polygons exterior ring, IRing interface has the method GetSubcurveEx, this method is perfect for my case since I can specify which direction I want the subcurve to follow. I can specify clockwise or counter clockwise, so I got both directions and simply picked the shortest. Here is how I done it.


       ExteriorPolygonRing.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, terminalPointOnParcel, false,outPoint, ref pointDistance, ref fromcr, ref rightSide);
ExteriorPolygonRing.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, handHoleParcelEdgePoint, false,outPoint2, ref pointDistance2, ref fromcr2, ref rightSide);
var clockWisePath = polyRing.GetSubcurveEx(pointDistance, pointDistance2, false, true, true);
var counterClockWisePath = polyRing.GetSubcurveEx(pointDistance, pointDistance2, false, false, true);

if (clockWisePath.Length < counterClockWisePath.Length) {
return clockWisePath;
}

return counterClockWisePath;
}

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...