ArcEngine图层属性查询
生活随笔
收集整理的這篇文章主要介紹了
ArcEngine图层属性查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
以下代碼實現了,根據給定的索引值layerindex,圖層名稱顯示在Label中,將圖層的屬性名稱添加到CheckedListBox中,將屬性展示在DataGridView中。
ILayer layer = mainForm.axMapControltemp.get_Layer(layerindex);IFeatureLayer pFeatureLayer = layer as IFeatureLayer;label1.Text = "您選擇的是:"+pFeatureLayer.Name+" 圖層";//加載屬性數據ITable table = pFeatureLayer.FeatureClass as ITable;dataGridView1.ColumnCount = table.Fields.FieldCount;//要先指定<span style="font-family: Arial, Helvetica, sans-serif;">dataGridView1的列數</span>for (int i = 0; i < table.Fields.FieldCount; i++){checkedListBox1.Items.Add(table.Fields.get_Field(i).Name.ToString());dataGridView1.Columns[i].Name = table.Fields.get_Field(i).Name.ToString();//屬性名賦給列名dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;//自適應列寬}for (int i = 0; i < table.RowCount(null); i++){int index = dataGridView1.Rows.Add();//獲取當前行for (int j = 0; j < table.Fields.FieldCount; j++){if (table.Fields.get_Field(j).Type == esriFieldType.esriFieldTypeGeometry)//Arcgis屬性中的特殊屬性類型處理dataGridView1.Rows[index].Cells[j].Value = GetFeatureShapeType(pFeatureLayer);elsedataGridView1.Rows[index].Cells[j].Value = table.GetRow(i).get_Value(j).ToString();}} private String GetFeatureShapeType(IFeatureLayer pFeatureLayer)//獲取圖層Shape類型的方法{String str;str = "error";if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint){str = "Point";}else if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline){str = "Line";}else if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon){str = "Polygon";}return str;}總結
以上是生活随笔為你收集整理的ArcEngine图层属性查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 淘宝获取sku具体详情的方法
- 下一篇: sping简介