ArcEngine开发:在要素类中删除要素的方法总结

删除feature,一个个删除就用IFeature.Delete方法即可,此处不再赘述,只写一种批量删除的方法,用于ITable是针对数据库进行操作的,所以速度很快。

The best approach to take when deleting features depends on two factors, how many features are being deleted and whether the data source is a local geodatabase or an ArcSDE geodatabase.

In the simplest case, a single feature that has already been retrieved can be deleted by callingIFeature.Delete. If bulk features are being deleted and the geodatabase is an ArcSDE geodatabase, the most efficient approach requires the use of a search cursor and the IFeature.Delete method.

On the other hand, if the geodatabase is a local geodatabase (a file or personal geodatabase), the most efficient method for bulk deletion is theITable.DeleteSearchedRows method.

方法1  ITable方法

///<summary>  
///删除某featurelayer中所有feature  
///</summary>  
///<param name="pLayer">操作的涂层</param>  
///<remarks>该方法可以给一个queryfilter,进行删除符合条件的features</remarks>  
private void DeleteAllFeatures(IFeatureLayer pLayer, <code></code>IQueryFilter queryFilter)  
{  
  ITable pTable = pLayer.FeatureClass as ITable;  
  pTable.DeleteSearchedRows(queryFilter);  
}

方法2 迭代featureClass方法

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();
}

 

转载于:https://www.cnblogs.com/arxive/p/5905407.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值