版本为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/