Geoprocessing the only difficult place is the parameters, which need to be set according to different circumstances,
I will use the Intersect method as an example, programming to achieve two layers of intersect.
Create a new project, add a reference, we use the tool intersect is in the Analysistools,
Add a button to the form, and then implement its method, as follows,
Don't forget to add a namespace
Using ESRI. Arcgis.esrisystem;
Using ESRI. Arcgis.geoprocessor;
Implement button click Method
private void Button1_Click (object sender, EventArgs e)
{
Structural Geoprocessor
ESRI. ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI. ArcGIS.Geoprocessor.Geoprocessor ();
Setting parameters
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";
Execute Intersect Tool
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);
}
}
}