直接上代码(以面要素为例)
//获取整个面图层的IGeometry private IGeometry getBasicGeometry_polygon(IFeatureClass pFeatureClass) { var pFeatureCursor = pFeatureClass.Search(null,false); var pF = pFeatureCursor.NextFeature(); IGeometry pUnionGeo = new PolygonClass(); pUnionGeo = pF.Shape; while (pF!=null) { var pUnionTopo = pUnionGeo as ITopologicalOperator; pUnionGeo = pUnionTopo.Union(pF.Shape); pF = pFeatureCursor.NextFeature(); } return pUnionGeo; }注意:上述代码是将图层中的所有面要素对象合并为一个整体,若要单独获取图层中的要素对象,可通过指定id获取,如
IGeometry pGeometry = pImportFeatureClass.GetFeature(0).Shape as IGeometry;