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相对来说就是基于局部图像 ...
随机推荐
- 二叉搜索树的第k个结点
给定一颗二叉搜索树,请找出其中的第k小的结点.例如, 5 / \ 3 7 /\ /\ 2 4 6 8 中,按结点数值大小顺序第三个结点的值为4. /* public class TreeNode { ...
- group by 和聚合函数
group by 的基本用法 group by做为分组来使用,后面为条件,可以有多个条件,条件相同的为一组,配合聚合函数进行相关统计.在不同数据库中用法稍有不同,这里只测试mysql和oracle. ...
- C#获取年龄段 几零后
/// <summary> /// 根据年龄获得年龄段 /// </summary> /// <param name="age"></pa ...
- 小meta的大作用
meta是用来在HTML文档中模拟HTTP协议的响应头报文.meta 标签用于网页的<head>与</head>中,meta 标签的用处很多.meta 的属性有两种:name和 ...
- Moon.Orm3.8技术全攻略
Moon.ORM技术全攻略 一.绪论 本文主要是针对Moon.ORM的技术的讨论及其使用使用指导.如有其它疑问,请留言.本文主要针对Moon.ORM3.9版本,同时将会对4.0做一个技术预览.本文从 ...
- Redhat7.2 如何修改主机名(hostname)?
Redhat7.2 在安装的时候,会默认生成主机名:localhost. 那么如何修改成自己想要的自己名? //格式为:用户名@主机名 比如: [root@localhost ~]# 修改成[roo ...
- 计算机中数据实体和数据表示形式(以C#为例)
摘自网络的一段话: “在程序代码中,可以用多种方式表示数据,十进制.十六进制.八进制都是常用的表示方式,但计算机内部永远就只使用二进制,与你写程序时用什么无关.你说要定义数组int a[10],其中涉 ...
- Windows Server 2016正式版14393英文版ISO镜像下载:_X64FRE_ZH-CN.ISO
http://care.dlservice.microsoft.com/dl/download/F/8/3/F83C7D26-787A-4F43-82B0-7C7BF8A12791/14393.0.1 ...
- C# 解析html —— 将html转为XHTML,然后利用Xml解析
呵呵,由于正则不熟,所以另谋出路——利用XML去解析html. 要想将抓取到的数据(直接抓取到的是byte[]) 转为XML文档(即XMLDocument对象),有两个要点: 一.判断编码(http ...
- 使用ExpandoObject来实现多个Model传送至视图
昨天Insus.NET有实现<使用ViewModel来实现多个Model传送至视图>http://www.cnblogs.com/insus/p/5594134.html 那今天Insus ...