ae_将面积小于1500的Feature同附近Feature进行合并
private void 合并1500图斑ToolStripMenuItem_Click(object sender, EventArgs e)
{
/*
*将图层中面积小于1500的图斑与之相同BSM且相邻的最大的图斑合并。
*/ if(axMapControl2.LayerCount<=0)
{ MessageBox.Show("请先添加图层再合并!"); }
else
{
pLayer = axMapControl2.get_Layer(0);//拿到层
pFLayer = pLayer as IFeatureLayer;//要素层
pFC = pFLayer.FeatureClass;//要素类 IFeatureCursor pFCursor = pFC.Search(null, false);//拿到该要素下的指针 IFeature pFeature = pFCursor.NextFeature();//递进光标的位置,拿到返回在该位置的要素对象 //创建表,获得要素ID,标识码,面积,用于筛选相同表示码,面积较小的要素
DataTable pTable = new DataTable(); DataColumn colID = new DataColumn("要素ID");//新建一个要素列,并设置列名
colID.DataType = System.Type.GetType("System.String");//设置该列类型
pTable.Columns.Add(colID);//塞入表 DataColumn colIdent = new DataColumn("标识码");
colIdent.DataType = System.Type.GetType("System.String");
pTable.Columns.Add(colIdent); DataColumn colArea = new DataColumn("面积");
colArea.DataType = System.Type.GetType("System.Double");
pTable.Columns.Add(colArea); int indexOfFID_HBTC_Z = pFC.FindField("FID_HBTC_Z");//返回要素类的指定字段的索引
int indexOfBSM = pFC.FindField("BSM");//返回要素类的指定字段的索引
int indexOfTBMJ = pFC.FindField("TBMJ");//返回要素类的指定字段的索引 while (pFeature != null)
{
//string FID_HBTC_Z = pFeature.get_Value(indexOfFID_HBTC_Z).ToString();
string BSM = pFeature.get_Value(indexOfBSM).ToString();
double TBMJ = (double)pFeature.get_Value(indexOfTBMJ); //挑选出小于1500的图斑
if (TBMJ < 1500)
{
//查找标识码相同的图斑
MergeFeature(pFeature); //IQueryFilter queryFilter1 = new QueryFilterClass();
//queryFilter1.WhereClause = "TBMJ=" + TBMJ.ToString();
//IFeatureCursor pFUpdateCursor = pFC.Update(queryFilter1, false);
//pFUpdateCursor.DeleteFeature(); } pFeature = pFCursor.NextFeature();
} MessageBox.Show("合并成功"); }
} private void MergeFeature(IFeature tarFeature)
{
int indexOfBSM = pFC.FindField("BSM");
string BSM = tarFeature.get_Value(indexOfBSM).ToString();//拿到当前feature的BSM值
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = "BSM=" + BSM; int tarindexOfTBMJ = pFC.FindField("TBMJ");
double tarTBMJ = (double)tarFeature.get_Value(tarindexOfTBMJ);//拿到当前feature的TBMJ值 IFeatureCursor updateCursor = pFC.Update(queryFilter, true);//按照查询,拿到更新要素的指针 IFeature feature1 = updateCursor.NextFeature();//拿到BSM相同的下一个要素 //feature1.get_Value(30); while (feature1 != null)
{
//是否相邻
ITopologicalOperator topo = (feature1.Shape as IPolygon) as ITopologicalOperator; IRelationalOperator rela = (feature1.Shape as IPolygon) as IRelationalOperator; //bool biii = rela.Touches(tarFeature.Shape);
if (rela.Touches(tarFeature.Shape))//如果相邻
{
int indexOfTBMJ = pFC.FindField("TBMJ");//从要素类中拿到该字段索引值
double TBMJ = (double)feature1.get_Value(indexOfTBMJ);//拿到该要素该字段的值 //合并图斑
if (TBMJ>=1500)
{
feature1.Shape = topo.Union(tarFeature.Shape) as IPolygon;
feature1.Store();
tarFeature.Delete();//删除被合并要素
break;
}
}
//ESRI.ArcGIS.SpatialStatisticsTools.CalculateAreas //updateCursor.Flush(); //是否。。。 feature1 = updateCursor.NextFeature(); } //TokayWorkspace.ComRelease(del_featcur);
//updateCursor = null; axMapControl2.ActiveView.Refresh();
}
ae_将面积小于1500的Feature同附近Feature进行合并的更多相关文章
- 【计算机视觉领域】常用的 feature 提取方法,feature 提取工具包
[计算机视觉领域]常用的 feature 提取方法,feature 提取工具包 利用 VL 工具包进行各种特征的提取: VL 工具包官网地址:http://www.vlfeat.org/index.h ...
- Feature Engineering versus Feature Extraction: Game On!
Feature Engineering versus Feature Extraction: Game On! "Feature engineering" is a fancy t ...
- feature.shape和feature.shapecopy的区别
以前在写AE代码的时候也没有注意到feature.shape和feature.shapecopy的区别,觉得两者也差不多: 今天写入库程序才明白过来. 如果取feature.shape,则得到的是该要 ...
- Google Play和基于Feature的过滤 —— Feature 参考手册
翻译自 Features Reference 下表列出了软/硬件Feature和权限的参考信息,它们被用于GooglePlay. 硬件feature 下面列出了被大多数当前发布的平台所支持的硬件功能描 ...
- tensorflow-TFRecord报错ValueError: Protocol message Feature has no "feature" field.
编写代码用TFRecord数据结构存储数据集信息是报错:ValueError: Protocol message Feature has no "feature" field.或和 ...
- 关于 Local feature 和 Global feature 的组合
关于 Local feature 和 Global feature 的组合 1.全局上下文建模:
- Feature Engineering and Feature Selection
首先,弄清楚三个相似但是不同的任务: feature extraction and feature engineering: 将原始数据转换为特征,以适合建模. feature transformat ...
- 机器学习-特征工程-Feature generation 和 Feature selection
概述:上节咱们说了特征工程是机器学习的一个核心内容.然后咱们已经学习了特征工程中的基础内容,分别是missing value handling和categorical data encoding的一些 ...
- local feature和global feature的理解
在计算机视觉方面,global feature是基于整张图像提取的特征,也就是说基于all pixels,常见的有颜色直方图.形状描述子.GIST等:local feature相对来说就是基于局部图像 ...
随机推荐
- Spring Boot异常处理详解
在Spring MVC异常处理详解中,介绍了Spring MVC的异常处理体系,本文将讲解在此基础上Spring Boot为我们做了哪些工作.下图列出了Spring Boot中跟MVC异常处理相关的类 ...
- JAVA 设计模式 中介者模式
用途 中介者模式 (Mediator) 用一个中介对象来封装一系列的对象交互.中介者使各对象不需要显示地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互. 中介者模式是一种行为型模式. 结 ...
- 两种读写配置文件的方案(app.config与web.config通用)
第一种方法:采用MS现有的ConfigurationManager来进行读写 using System.Configuration; namespace Zwj.TEMS.Common { publi ...
- VUE2.0不可忽视的很多变化
今天使用webpack-sample初始一个vue-cli项目,在app.vue文件中添加了个钩子函数ready,可是ready内的事件一直不执行,检查了webpack文件和package.json也 ...
- 优化MySchool数据库总结
- orleans/Documentation
福利 奥尔良的主要好处是︰开发人员工作效率,甚至为非专家程序员;和默认的透明可伸缩性与程序员没有特别努力.我们扩大每个下面这些好处. 开发人员的生产力 奥尔良的编程模型通过提供以下关键的抽象. 担保和 ...
- 使用archiver在nodejs下打包
archiver是一个在nodejs中能跨平台实现打包功能的模块,可以打zip和tar包,是一个比较好用的三方模块. 使用前先安装archiver模块. npm install archiver 建立 ...
- SQLite中文排序
定义一个类: using System.Data.SQLite; namespace DAL { /// <summary> /// SQLite中文排序 /// </summary ...
- 【FTP】C# System.Net.FtpClient库连接ftp服务器(上传文件)
如果自己单枪匹马写一个连接ftp服务器代码那是相当恐怖的(socket通信),有一个评价较高的dll库可以供我们使用. 那就是System.Net.FtpClient,链接地址:https://net ...
- Web API应用架构在Winform混合框架中的应用(2)--自定义异常结果的处理
在上篇随笔<Web API应用架构在Winform混合框架中的应用(1)>中我介绍了关于如何在Winfrom里面整合WebAPI,作为一个新型数据源的接入方式,从而形成了三种不同的数据提供 ...