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进行合并的更多相关文章

  1. 【计算机视觉领域】常用的 feature 提取方法,feature 提取工具包

    [计算机视觉领域]常用的 feature 提取方法,feature 提取工具包 利用 VL 工具包进行各种特征的提取: VL 工具包官网地址:http://www.vlfeat.org/index.h ...

  2. Feature Engineering versus Feature Extraction: Game On!

    Feature Engineering versus Feature Extraction: Game On! "Feature engineering" is a fancy t ...

  3. feature.shape和feature.shapecopy的区别

    以前在写AE代码的时候也没有注意到feature.shape和feature.shapecopy的区别,觉得两者也差不多: 今天写入库程序才明白过来. 如果取feature.shape,则得到的是该要 ...

  4. Google Play和基于Feature的过滤 —— Feature 参考手册

    翻译自 Features Reference 下表列出了软/硬件Feature和权限的参考信息,它们被用于GooglePlay. 硬件feature 下面列出了被大多数当前发布的平台所支持的硬件功能描 ...

  5. tensorflow-TFRecord报错ValueError: Protocol message Feature has no "feature" field.

    编写代码用TFRecord数据结构存储数据集信息是报错:ValueError: Protocol message Feature has no "feature" field.或和 ...

  6. 关于 Local feature 和 Global feature 的组合

     关于  Local feature 和 Global feature 的组合     1.全局上下文建模:  

  7. Feature Engineering and Feature Selection

    首先,弄清楚三个相似但是不同的任务: feature extraction and feature engineering: 将原始数据转换为特征,以适合建模. feature transformat ...

  8. 机器学习-特征工程-Feature generation 和 Feature selection

    概述:上节咱们说了特征工程是机器学习的一个核心内容.然后咱们已经学习了特征工程中的基础内容,分别是missing value handling和categorical data encoding的一些 ...

  9. local feature和global feature的理解

    在计算机视觉方面,global feature是基于整张图像提取的特征,也就是说基于all pixels,常见的有颜色直方图.形状描述子.GIST等:local feature相对来说就是基于局部图像 ...

随机推荐

  1. SQLServer学习笔记系列3

    一.写在前面的话 今天又是双休啦!生活依然再继续,当你停下来的时候,或许会突然显得不自在.有时候,看到一种东西,你会发现原来在这个社会上,优秀的人很多,默默 吃苦努力奋斗的人也多!星期五早上按时上班, ...

  2. 使用国内镜像加速下载Android SDK

    本文转自:http://blog.kuoruan.com/24.html.感谢原作者. 什么是Android SDK SDK:(software development kit)软件开发工具包.被软件 ...

  3. 解决VS Code调试.NET Core应用遇到的坑

    为什么会有”坑“ 博客园里有好多介绍怎么使用VS Code以及调试.NET Core的文章,但是都是基于直接构建Asp.Net Core Mvc单项目的,有什么区别呢! (1).我们这次遇到的坑是在多 ...

  4. 【转】 NoSQL初探之人人都爱Redis:(4)Redis主从复制架构初步探索

    一.主从复制架构简介 通过前面几篇的介绍中,我们都是在单机上使用Redis进行相关的实践操作,从本篇起,我们将初步探索一下Redis的集群,而集群中最经典的架构便是主从复制架构.那么,我们首先来了解一 ...

  5. SQL Server 抛出自定义异常,由C#程序俘获之并进行相应的处理

    最近一直在找可以自定义异常,并用C#程序捕获并进行相应的处理,试了很多方法都没有成功.今天终于找到了不错的方法.所以转载并分享给大家. 摘自:http://www.cnblogs.com/scottc ...

  6. <if><else/></if> 语句

    <li> <if condition="$nid eq 'partner'"> <a href="javascript:void(0);&q ...

  7. Tsung测试Tigase

    用两台主机坐Tigase的Tsung测试,其中1台运行Tigase,另1台运行Tsung. 1.Tigase服务器设置 tigase.conf: #osgiEnabled=(true|false) # ...

  8. Mysql存储过程(四)——异常处理

    http://blog.csdn.net/crazylaa/article/details/5368421 有时候,不希望存储过程抛出错误中止执行,而是希望返回一个错误码. MySQL 支持异常处理, ...

  9. NYOJ:题目490 翻译

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=490 这题的输入输出格式好像描述的不太清楚,1)可能是所有数据都完成输入,然后再输出(解法 ...

  10. BZOJ 2467 解题报告

    对于一个合格的程序员来说,掌握一定的数学知识是非常必要的,所以这次就开个数学专题玩玩. 不多说啥,上题目,我们直接分析题目! 首先ORZ stonepage神犇,一眼就看出我把快速幂写成快速乘了…… ...