Call Arctoolbox tool (geoprocessing) in Arcengine

Source: Internet
Author: User

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);
}
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.