当前位置:文档之家› arcengine 两个图层叠加获得长度和面积

arcengine 两个图层叠加获得长度和面积

arcengine 两个图层叠加获得,获得地区图层中各地区的对应的类型的面积 2013-02-04 09:46:07| 分类: ARCGIS | 标签:ae 面面叠加 |举报|字号?订阅 ///?

///?两个图层叠加获得,获得地区图层中各地区的对应的类型的面积 ///? ///?边界 ///?类型 ///?名字 ///?类型字段 private?DataTable?getTypeAreaPerRange(string?pathArea,?string?pathType,?string?areaNameColumn,?string?typeColumn) { DataTable?dt?=?new?DataTable(); dt.Columns.Add("地名"); dt.Columns.Add("长度"); //?HashTable?hs?=?new?HashTable(); //分别获取Polyline和Polygon的要素类 IFeatureLayer?pFeatureLayerPolygonArea?=?https://www.doczj.com/doc/943201520.html,yer.getShpLayer(pathArea,?"polygon1"); IFeatureLayer?pFeatureLayerPolygonType?=?https://www.doczj.com/doc/943201520.html,yer.getShpLayer(pathType,?"polygon2"); IFeatureClass?pFeatureClassPolygonArea?=?pFeatureLayerPolygonArea.FeatureClass; IFeatureClass?pFeatureClassPolygonType?=?pFeatureLayerPolygonType.FeatureClass; IFeatureCursor?pPolyCursor?=?pFeatureClassPolygonArea.Search(null,?false); IFeature?pPolyFeature?=?pPolyCursor.NextFeature(); int?nameIndex?=?pPolyFeature.Fields.FindField(areaNameColumn); while?(pPolyFeature?!=?null) { Application.DoEvents(); //IFeature?pFeaturePolygon?=?pFeatureClassPolygon.GetFeature(18); IPolygon?pPolygon?=?pPolyFeature.ShapeCopy?as?IPolygon; //获取线要素类的所有要素 IFeatureCursor?pFeatureCursorPolyType?=?pFeatureClassPolygonType.Search(new?QueryFilterClass(),?false); IFeature?pFeaturePolyType?=?pFeatureCursorPolyType.NextFeature(); //遍历每一个线要素 double?totalArea?=?0; while?(pFeaturePolyType?!=?null) { //求该线与某个面要素相交的几何线段 IPolygon?pPolyType?=?pFeaturePolyType.ShapeCopy?as?IPolygon; ITopologicalOperator?pTopologicalOperator?=?pPolyType?as?ITopologicalOperator; IGeometry?Geo?= pTopologicalOperator.Intersect(pPolygon,?esriGeometryDimension.esriGeometry2Dimension); IFeatureBuffer?FeaBuffer?=?pFeatureClassPolygonType.CreateFeatureBuffer(); FeaBuffer.Shape?=?Geo; IArea?pArea?=?(IArea)FeaBuffer.Shape;

totalArea?+=?pArea.Area; //累加面内线要素几何线段的长度 pFeaturePolyType?=?pFeatureCursorPolyType.NextFeature(); } DataRow?dr?=?dt.NewRow(); dr[0]?=?pPolyFeature.get_Value(nameIndex); dr[1]?=?totalArea; dt.Rows.Add(dr); // MessageBox.Show(totalLength.ToString()); pPolyFeature?=?pPolyCursor.NextFeature(); } dataGridView1.DataSource?=?dt; tabControl1.SelectTab(tabPage2); return?dt; }

相关主题
文本预览
相关文档 最新文档