ArcEngine GP工具使用实例

版本为ArcEngine10.1

1、Analysis Tools--OverLay 相交Intersect工具实例

Geoprocessor geoprocessor = new Geoprocessor();
geoprocessor.OverwriteOutput = true;
ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
IGpValueTableObject gpValueTableObject = new GpValueTableObjectClass();//对两个要素类进行相交运算
gpValueTableObject.SetColumns(2);
object o1 = featureClass1;//输入IFeatureClass 1 
object o2 = featureClass2;//输入IFeatureClass 2 
gpValueTableObject.AddRow(ref o1);
gpValueTableObject.AddRow(ref o2);
intersect.in_features = gpValueTableObject;
intersect.out_feature_class = @"shp存放路径\test.shp";
geoprocessor.Execute(intersect, null);

2、DataManager Tools--Generalization 融合Dissolve工具实例  融合多个字段
Geoprocessor geoprocessor = new Geoprocessor();
geoprocessor.OverwriteOutput = true;
ESRI.ArcGIS.DataManagementTools.Dissolve dissolve = new ESRI.ArcGIS.DataManagementTools.Dissolve();
dissolve.in_features = GBTBfeatureClass;
IGpValueTableObject pObject = new GpValueTableObjectClass();//对多个字段进行融合添加
pObject.SetColumns(1);
pObject.AddRow("字段1");
pObject.AddRow("字段2");
pObject.AddRow("字段3");
dissolve.dissolve_field = pObject;
dissolve.out_feature_class = @"shp存放路径\test.shp";
geoprocessor.Execute(dissolve, null);

3、DataManager Tools--Fields 添加字段addField工具实例 添加两个字段
Geoprocessor geoprocessor = new Geoprocessor();
geoprocessor.OverwriteOutput = true;
ESRI.ArcGIS.DataManagementTools.AddField addField = new ESRI.ArcGIS.DataManagementTools.AddField();
addField.in_table = table;//ITable类型参数
addField.field_name = "字段1";
addField.field_type = "TEXT";
addField.field_length = 200;
AddField addField2 = new AddField();
addField2.in_table = table2;//ITable类型参数
addField2.field_name = "字段2";
addField2.field_type = "TEXT";
addField2.field_length = 50;
geoprocessor.Execute(addField, null);

geoprocessor.Execute(addField2, null);


GP执行错误捕捉:

Geoprocessor gp = new Geoprocessor();
try
    {
        ........
        gp.Execute("CreateFeatureDataset_management", parameters, null);
    }
    catch (Exception ex)
    {
        object sev = null;
        string msgs = gp.GetMessages(ref sev);
    }


参:http://www.cnblogs.com/zhangjun1130/archive/2010/05/26/1744472.html

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Using_ArcObjects_as_tool_input/00010000041n000000/

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值