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. J2EE修炼之四书五经[转自2004年程序员]

    J2EE修炼之四书五经 作者:彭晨阳 J2EE其实没有四书五经,因为J2EE一直如汹涌澎湃的大江,推陈出新,不断高速发展,这是一种带领我们走向未来的技术.当然,如何在这种气势如虹的潮流之中不至于迷失方 ...

  2. java设计模式(三)--抽象工厂模式

    转载:http://zz563143188.iteye.com/blog/1847029 前面的工厂方法模式虽然清晰,但还是感觉有些繁琐,通常使用的还是抽象工厂模式. 工厂方法模式有一个问题就是,类的 ...

  3. java中map插入相同的key

    测试用例: package test; import org.junit.Test; import po.Person; import java.util.HashMap; import java.u ...

  4. Elasticsearch聚合初探——metric篇

    Elasticsearch是一款提供检索以及相关度排序的开源框架,同时,也支持对存储的文档进行复杂的统计--聚合. 前言 ES中的聚合被分为两大类:Metric度量和bucket桶(原谅我英语差,找不 ...

  5. 《Inside UE4》-0-开篇

    <Inside UE4>-0-开篇 InsideUE4   前言 VR行业发展是越来越火热了,硬件设备上有HTC VIVE,Oculus rift,PS VR,各种魔镜:平台上有Steam ...

  6. Spring MVC 原理介绍(执行流程)

    Spring MVC工作流程图   图一   图二    Spring工作流程描述       1. 用户向服务器发送请求,请求被Spring 前端控制Servelt DispatcherServle ...

  7. a:link a:visited a:hover a:active四种伪类选择器的区别

    a:link选择网页中所有没有被visited的a标签,就是没有鼠标悬停hover或者点击click(a链接没有被访问时的样式) a:visited选择网页中所有已经被click的a链接,用来告诉用户 ...

  8. IOS ID生成器

    // // IdGenerator.m // Copyright (c) 2014年 青岛拓宇网络科技有限公司. All rights reserved. // #import "IdGen ...

  9. C#以管理员身份运行程序

    using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; names ...

  10. 插入排序---直接插入排序算法(Javascript版)

    将n个元素的数列分为已有序和无序两个部分. 数列:{a1,a2,a3,a4,…,an} 将该数列的第一元素视为有序数列,后面都视为无序数列: {{a1},{a2,a3,a4,…,an}} 将无序数列中 ...