ArcGIS Engine 创建索引(属性索引)——提高查询效率

博客指出当对FeatureClass某列频繁查找且数据量大时,建立索引可提高查询效率,并介绍用ArcGIS Engine建立属性索引。还提到使用几何包对象过滤时,为ISpatialFilter对象设置Geometry属性前,对几何包对象创建空间索引能提升效率,给出了创建空间索引的示例代码。

众所周知,建立索引可以提高查询的效率,当对FeatureClass中的某一列频繁的查找,且数据量比较大时,建立索引是非常有必要的。

这里介绍一下,用 ArcGIS Engine 来建立一个属性索引。

复制代码

    IIndex pIndex = new IndexClass();  
    IIndexEdit pIndexEdit = pIndex as IIndexEdit;  
    IFields pFields = new FieldsClass();  
    IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;  
    int feildindex = pFeatureClass.Fields.FindField("Name");  
    IField pField = pFeatureClass.Fields.Field[feildindex];  
    pFieldsEdit.FieldCount_2 = 1;  
    pFieldsEdit.set_Field(0, pField);  
    pIndexEdit.Fields_2 = pFields;  
    pIndexEdit.Name_2 = zidField;  
    pIndexEdit.IsAscending_2 = true;  
    pFeatureClass.AddIndex(pIndex);  

 

 

如果使用几何包对象作为过滤的几何图形,在为ISpatialFilter对象设置Geometry属性之前,先对几何包对象创建空间索引,这样能大大提高查询的效率,下面是创建空间索引的示例代码:

// 将几何包对象转换到ISpatialIndex对象上去
ISpatialIndex spatialIndex = (ISpatialIndex)geometryBag;
spatialIndex.AllowIndexing = true;
spatialIndex.Invalidate();
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值