GIS数据的插入,删除,更新(ArcEngine)

GIS数据的插入,删除,更新(ArcEngine)


发布日期: 2016-05-14 更新日期: 2016-05-14 编辑:zhangxiang 浏览次数: 5355

标签:

摘要: 插入数据 利用Insert Cursors和featureBuffer IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer(); IFeatureCursor featureCurso...

插入数据

利用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();

直接进行数据插入(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();

数据删除 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();

}

数据更新 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();

}

关注公众号
获取免费资源

随机推荐


Copyright © Since 2014. 开源地理空间基金会中文分会 吉ICP备05002032号

Powered by TorCMS

OSGeo 中国中心 邮件列表

问题讨论 : 要订阅或者退订列表,请点击 订阅

发言 : 请写信给: osgeo-china@lists.osgeo.org