显示栅格图层和矢量图层的属性表(AE开发)
2017-07-12 14:33
351 查看
转载自:http://blog.csdn.net/xwebsite/article/details/4850383
显示栅格图层和矢量图层的属性表
定义一个函数showAttributeTable()用于显示栅格图层或矢量数据图层的属性表,其参数pLyr为要显示属性的图层,在程序中添加一个dataGridView控件用于显示属性表。该函数的代码如下:
显示栅格图层和矢量图层的属性表
定义一个函数showAttributeTable()用于显示栅格图层或矢量数据图层的属性表,其参数pLyr为要显示属性的图层,在程序中添加一个dataGridView控件用于显示属性表。该函数的代码如下:
private void showAttributeTable(ILayer pLyr) { if (pLyr is IFeatureLayer) { DataTable pTable = new DataTable(); IFeatureLayer pFealyr = pLyr as IFeatureLayer; IFeatureClass pFCls = pFealyr.FeatureClass; string shape = ""; if (pFCls.ShapeType == esriGeometryType.esriGeometryPoint) shape = "Point"; else if (pFCls.ShapeType == esriGeometryType.esriGeometryPolyline) shape = "Polyline"; else if (pFCls.ShapeType == esriGeometryType.esriGeometryPolygon) shape = "Polygon"; for (int i = 0; i < pFCls.Fields.FieldCount; i++) { pTable.Columns.Add(pFCls.Fields.get_Field(i).Name); } IFeatureCursor pCursor = pFCls.Search(null, false); int ishape = pFCls.Fields.FindField("Shape"); IFeature pFea = pCursor.NextFeature(); while (pFea != null) { DataRow pRow = pTable.NewRow(); for (int i = 0; i < pFCls.Fields.FieldCount; i++) { if (i == ishape) { pRow[i] = shape; continue; } pRow[i] = pFea.get_Value(i).ToString(); } pTable.Rows.Add(pRow); pFea = pCursor.NextFeature(); } dataGridView1.DataSource = pTable; } else if (pLyr is IRasterLayer) { IRasterLayer pRlyr = pLyr as IRasterLayer; IRaster pRaster = pRlyr.Raster; IRasterProps pProp = pRaster as IRasterProps; pProp.PixelType = rstPixelType.PT_LONG; if (pProp.PixelType == rstPixelType.PT_LONG) { IRasterBandCollection pBcol = pRaster as IRasterBandCollection; IRasterBand pBand = pBcol.Item(0); ITable pRTable = pBand.AttributeTable; DataTable pTable = new DataTable(); for (int i = 0; i < pRTable.Fields.FieldCount; i++) pTable.Columns.Add(pRTable.Fields.get_Field(i).Name); ICursor pCursor = pRTable.Search(null, false); IRow pRrow = pCursor.NextRow(); while (pRrow != null) { DataRow pRow = pTable.NewRow(); for (int i = 0; i < pRrow.Fields.FieldCount; i++) { pRow[i] = pRrow.get_Value(i).ToString(); } pTable.Rows.Add(pRow); pRrow = pCursor.NextRow(); } dataGridView1.DataSource = pTable; } } }
相关文章推荐
- 显示栅格图层和矢量图层的属性表(AE开发)
- QGis二次开发基础 -- 矢量图层属性图表显示
- AE构建获取栅格图层属性表(ITable)
- ArcEngine二次开发_02(鼠标移过图层中显示特定的属性信息)
- AE开发中栅格图层实现分级渲染
- AE开发图层右键打开属性表
- ArcGIS API for Silverlight之Web Mapping开发:根据图层属性查询、定位、高亮显示并显示标注(2)
- ArcGIS API for Silverlight之Web Mapping开发:根据图层属性查询、定位、高亮显示
- 基于Skyline的TerraExplorer6.1.1如何通过二次开发实现矢量图层的空间查询和属性查询
- Qgis开发3-加载矢量、栅格图层
- ArcEngine二次开发_04(鼠标点击图层点显示属性(两个及以上))
- AE二次开发-判断栅格图层是否存在属性表,获取栅格字段的唯一值
- AE+C#开发问题之二——axTOCControl控件图层不显示问题
- 【Arcgis Engine开发】AE开发把影像或者矢量加载到图层
- QGis二次开发基础 -- 矢量图层的显示样式
- AE实现右键点击TOC控件任意图层显示属性表
- AE实现右键点击TOC控件任意图层显示属性表
- C#基础系列:开发自己的窗体设计器(PropertyGrid显示中文属性名)
- AE开发----图层操作
- C#+AE 调整TOCControl控件中图层的显示顺序