阅读背景:

ArcGIS Engine中调用GP的两种方法

来源:互联网 

借用别人的东西,将这两种方法放在一起:

第一种,分别设置参数:


 

//添加命名空间
 using ESRI.ArcGIS.esriSystem;
 using ESRI.ArcGIS.Geoprocessor;
 
//实现button click方法
 private void button1_Click(object sender, EventArgs e)
 {
 //构造Geoprocessor
 Geoprocessor gp = new Geoprocessor();
 //设置参数
 ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
 intersect.in_features = @"F:\foshan\Data\wuqutu_b.shp;F:\foshan\Data\world30.shp";
 intersect.out_feature_class = @"E:\intersect.shp";
 intersect.join_attributes = "ONLY_FID";
 //执行Intersect工具
 RunTool(gp, intersect, null);
 }
 
private void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)
 {
 // Set the overwrite output option to true
 geoprocessor.OverwriteOutput = true;
 
try
 {
 geoprocessor.Execute(process, null);
 ReturnMessages(geoprocessor);
 
}
 catch (Exception err)
 {
 Console.WriteLine(err.Message);
 ReturnMessages(geoprocessor);
 }
 }
 
// Function for returning the tool messages.
 private void ReturnMessages(Geoprocessor gp)
 {
 string ms = "";
 if (gp.MessageCount > 0)
 {
 for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
 {
 ms += gp.GetMessage(Count);
 }
 }
 //添加命名



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: