项目中遇到需要将面转成线,网上的大多资料都是使用GP工具,对整个图层进行面转线,这里的方法可以对单个要素进行面转线操作。代码如下:
IPolygon polygon = pFeature.Shape as IPolygon;
ISegmentCollection segmentCollction = polygon as ISegmentCollection;
ISegmentCollection polyline = new Polyline() as ISegmentCollection;
object missing = Type.Missing;
for (int m = 0; m < segmentCollction.SegmentCount; m++)
{
ISegment pSeg = segmentCollction.get_Segment(m);
polyline.AddSegment(pSeg, ref missing, ref missing);
}
IGeometry pGeo = polyline as IPolyline;
IFeature pInFeatureLine = pFeatureClass.CreateFeature();//线图层创建的要素
pInFeatureLine .Shape = pGeo ;
版权声明:本文为u013929811原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。