首页 > 代码库 > ArcGIS 中要素的查询与修改
ArcGIS 中要素的查询与修改
转自nimeila的回答 求C# ArcGIS Engine修改选中要素的属性,单要素都行
RLAlterFrm RLalter = new RLAlterFrm(); RLalter.ShowDialog(); string AlterID = RLalter.textBox1.Text; string AlterRP = RLalter.textBox2.Text; string AlterC = RLalter.textBox3.Text; axMapControl1.ClearLayers(); axMapControl1.Refresh(); try { string strFileName = Application.StartupPath + @"\数据\Roadlamp.mxd"; //在数据视图中加载地图,供查询操作 if (axMapControl1.CheckMxFile(strFileName)) { axMapControl1.LoadMxFile(strFileName); } else { MessageBox.Show("错误的数据路径:" + strFileName); } } catch (Exception ex) { MessageBox.Show("Error01 in MainForm.cs" + ex.Message); } axMapControl1.Refresh(); string strQK = RLalter.getQueryKey();//获取查询值 //找到图层 IFeatureLayer pfeaturelayer = new FeatureLayer(); pfeaturelayer = axMapControl1.get_Layer(0) as IFeatureLayer; //找到要素 IQueryFilter pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = "[RL_ID] = ‘" + strQK + "‘"; IFeatureCursor pFeatureCur = pfeaturelayer.Search(pQueryFilter, false); IFeature pFeature = null; pFeature = pFeatureCur.NextFeature(); if (null == pFeature) { MessageBox.Show("对不起!该元素不存在"); } else { IFields pFields = pFeature.Fields; IFeatureClass pFeatureClass = pfeaturelayer.FeatureClass; //修改属性值 int field1 = pFields.FindField("RL_ID"); int field2 = pFields.FindField("RL_RP"); int field3 = pFields.FindField("RL_C"); pFeature.set_Value(field1, AlterID); pFeature.set_Value(field2, AlterRP); pFeature.set_Value(field3, AlterC); pFeature.Store(); MessageBox.Show("修改成功!","提示"); } }
ArcGIS 中要素的查询与修改
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。