GIS中复杂多边形的处理(例如孤岛、空心多边形)

对于ArcGIS中的复杂多边形处理起来有时候比较棘手,我们可以使用IPolygon4接口,遍历IPolygon当中多有的外环和内环

下面给出代码示例:

 public  void PolygonToRing(IPolygon4 polygon)
        {
            IGeometryBag exteriorRingGeometryBag = polygon.ExteriorRingBag;
            IGeometryCollection exteriorRingGeometryCollection = exteriorRingGeometryBag as IGeometryCollection;
            for (int i = 0; i < exteriorRingGeometryCollection.GeometryCount; i++)
            {
                List PointResult = new List();
                IGeometry exteriorRingGeometry = exteriorRingGeometryCollection.get_Geometry(i);
                IPointCollection exteriorRingPointCollection = exteriorRingGeometry as IPointCollection;
                ReadPoints(exteriorRingPointCollection,PointResult);
                CreateJson(PointResult);


                IGeometryBag interiorRingGeometryBag = polygon.get_InteriorRingBag(exteriorRingGeometry as IRing);
                IGeometryCollection interiorRingGeometryCollection = interiorRingGeometryBag as IGeometryCollection;
                for (int k = 0; k < interiorRingGeometryCollection.GeometryCount;k++ )
                {
                    IGeometry interiorRingGeometry = interiorRingGeometryCollection.get_Geometry(k);
                    IPointCollection interiorRingPointCollection = interiorRingGeometry as IPointCollection;
                    ReadPoints(interiorRingPointCollection, PointResult);
                    CreateJson(PointResult);
                }
            }
        }

        /// 
        /// 获取结果多边形节点坐标
        /// 
        /// 点集合
        private void ReadPoints(IPointCollection ptCol, List PointResult)
        {
            IPoint pnt;
            for (int i = 0; i < ptCol.PointCount; i++)
            {
                pnt = ptCol.get_Point(i);
                PointResult.Add(pnt);
            }
        }
ARCGIS复杂多边形基础知识讲解
http://www.cnblogs.com/willwayer/archive/2010/09/13/1824721.html

你可能感兴趣的:(ArcGIS,Engine,arcgis,arcengine)