ArcEngine查询、添加、删除要数的方法

转自原文ArcEngine查询、添加、删除要数的方法

1、查找数据

1)、利用FeaturCursor进行空间查询

//空间查询

ISpatialFilter spatialFilter = new SpatialFilterClass();

spatialFilter.Geometry = envelope;//指定几何体

String shpFld = featureClass.ShapeFieldName;

spatialFilter.GeometryField = shpFld;

spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//相交

IQueryFilter queryFilter = new QueryFilterClass();

queryFilter = (IQueryFilter)spatialFilter;

IFeatureCursor searchCursor = featureClass.Search(queryFilter, true);

IFeature feature = searchCursor.NextFeature();

int n = 0;

while (feature != null){

n++;

feature = baseCursor.NextFeature();

}

2)、利用FeatureCursor在选择集中进行查询

IFeatureSelection pFeatureSelectio = pFeatureLayer as IFeatureSelection;

ICursor ppCursor;

pFeatureSelectio.SelectionSet.Search(null, false, out ppCursor);

IFeatureCursor pFeatureCursor = ppCursor as IFeatureCursor;

IFeature pFeature = pFeatureCursor.NextFeature();

3)、利用FeatureCursor进行属性查询

IQueryFilter pQueryFilter = new QueryFilterClass();

pQueryFilter.WhereClause = "PROJECTCODE = ‘" + this.ProjectNumTextBox.Text.Trim() + "‘";

IFeatureCursor pFeatureCursor = LineFeaClass.Search(pQueryFilter, false);

IFeature pFeatureIfExit = pFeatureCursor.NextFeature();

2、
插入数据

1)、利用Insert Cursors和featureBuffer

IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();

IFeatureCursor featureCursor = featureClass.Insert(true);

object featureOID;

featureBuffer.set_Value(featureBuffer.Fields.FindField("InstBy"), "B Pierce");

for (int ic = 0; ic < 99; ic++)

{

featureBuffer.Shape = geometry;

featureOID = featureCursor.InsertFeature(featureBuffer);

}

featureBuffer.set_Value(featureBuffer.Fields.FindField("InstBy"), "K Johnston");

for (int ic = 0; ic < 99; ic++)

{

featureBuffer.Shape = geometry

featureOID = featureCursor.InsertFeature(featureBuffer);

}

featureCursor.Flush();

2)、直接进行数据插入(Feature.Store方法)

IFeature newLineFeature = LineFeaClass.CreateFeature();

newLineFeature.Shape = pFeature.Shape;

int ii = newLineFeature.Fields.FindField(AreaZonalName);

if (ii > 0)

{

newLineFeature.set_Value(ii, this.AnalysAreaComboBox.Text.Trim());

}

newLineFeature.Store();

注:最好将编辑操作对象中,如下:

IDataset dataset = (IDataset)featureClass;

IWorkspace workspace = dataset.Workspace;

// Cast the workspace to the IWorkspaceEdit interface.

IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

// Start an edit session and edit operation.

workspaceEdit.StartEditing(true);

workspaceEdit.StartEditOperation();

//在这里编写添加要素的代码。。。。。。。。。。。

// Stop editing.

workspaceEdit.StopEditOperation();

workspaceEdit.StopEditing(true);

3、数据删除 delete

IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Parcels");

IQueryFilter queryFilter = new QueryFilterClass();

queryFilter.WhereClause = "ZONING_S = ‘R‘";

IFeatureCursor updateCursor = featureClass.Update(queryFilter, false);

IFeature feature = updateCursor.NextFeature();

int m = 0;

while (feature != null)

{

m++;

updateCursor.DeleteFeature(feature);

feature = updateCursor.NextFeature();

}

4、
数据更新
update

IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Parcels");

// 属性查询

IQueryFilter queryFilter = new QueryFilterClass();

queryFilter.WhereClause = "ZONING_S = ‘U‘";

//利用FeatureCursor进行数据更新

IFeatureCursor updateCursor = featureClass.Update(queryFilter, false);

int fieldindex = featureClass.FindField("ZONING_S");

IFeature feature = updateCursor.NextFeature();

int m = 0;

while (feature != null)

{

m++;

feature.set_Value(fieldindex, "X");

updateCursor.UpdateFeature(feature);

feature = updateCursor.NextFeature();

}

0
0
时间: 2024-10-05 18:27:15

ArcEngine查询、添加、删除要数的方法的相关文章

MySQL中查询、删除重复记录的方法大全

前言 本文主要给大家介绍了关于MySQL中查询.删除重复记录的方法,分享出来供大家参考学习,下面来看看详细的介绍: 查找所有重复标题的记录: ? 1 select title,count(*) as count from user_table group by title having count>1; ? 1 SELECT * FROM t_info a WHERE ((SELECT COUNT(*) FROM t_info WHERE Title = a.Title) > 1) ORDER

DataGridView连接Sql数据库 功能 查询 添加 删除 修改

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace _03大项目 { public partial cla

查询及删除重复记录的方法

1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select * from peoplewhere peopleId in (select  peopleId  from  people  group  by  peopleId  having  count(peopleId) > 1) 2.删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录delete from people where peopleId  in (

EF6基础系列(12)--- EF进行批量添加/删除

EF6添加了批量添加/删除实体集合的方法,我们可以使用DbSet.AddRange()方法将实体集合添加到上下文,同时实体集合中的每一个实体的状态都标记为Added,在执行SaveChange()方法时为每个实体执行Insert操作:同样的我们使用DbSet.RemoveRange()方法将集合中的所有实体都标记为deleted状态,在执行SaveChange()方法时为每一条数据执行delete操作. 通过AddRange()和RemoveRange()方法可以有效提升性能,所以建议在进行不批

win2003添加删除windows组件中无iis应用程序服务器项的解决方法

一.解决方法如下: 1.开始 -- 运行 ,输入c:\Windows\inf\sysoc.inf ,会打开这个文件; 找到 "[Components]" 这一段,在下面添加: " iis=iis.dll,OcEntry,iis.inf,,7 " .之后保存并关闭. 2.下载 iis6 安装包(附件下载), 解压到 D:/ 根目录下,方便使用; 3.开始 -- 运行 -- cmd ,打开命令行模式.执行下面两条命令: EXPand d:\IIS6\iis.dl_ c:

mongodb replica set 添加/删除节点方法--http://www.ii123.com/jc/bc/bczh/258948.html

replica set多服务器主从,添加,删除节点,肯定会经常遇到的.下面详细说明一下,添加,删除节点的2种方法. 一,利用rs.reconfig,来添加,删除节点 1,添加节点  代码如下   repmore:PRIMARY> config = {_id:"repmore",members:[{_id:0,host:'127.0.0.1:27017',priority :2},{_id:1,host:'127.0.0.1:27018',priority:1}]};   //添加

往一个容器 添加删除子元素演示,和,给数 组添加自定义方法

/*2015 12 2 往一个容器 添加删除子元素演示*/ //全局静态变量的写法 (function(){ //获取元素对象 var container = document.getElementById("container"); var btnAdd = document.getElementById("btnAdd"); var btnDel = document.getElementById("btnDel"); //定义数组 var

添加删除Windows组件里没有IIS(Internet信息服务)项的解决方法

现在,安装操作系统,对于个人用户而言基本都是用Ghost的,用原盘安装的,已经很少了 但是,使用克隆盘安装的系统,基本上都是没有安装IIS(Internet信息服务)的,对于做开发测试的人来说,是很不方便的,通常需要自己在 “添加/删除Windows组件” 里面,把IIS重新装上. IIS的独立安装包,已经很普遍了,网上N多,也省去了找原始系统安装盘的麻烦,很是方便,但是,有些Ghost的系统,为了精简和瘦身,对系统的一些默认设置进行了更改,隐藏和消减了一些安装项,这其中就包括IIS:使得在“添

MySQL的JDBC判断查询结果是否为空以及获取查询结果行数的方法

判断查询结果是否为空 在JDBC中没有方法hasNext去判断是否有下一条数据,但是我们可以使用next方法来代替. 看next方法的官方解释: boolean next() throws Moves the cursor forward one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method n