Executing tools (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Using geoprocessing > Executing tools (ArcObjects .NET 10.6 SDK)

Executing tools


In this topic


About roadmap to executing tools

Geoprocessing is a fundamental part of ArcGIS. Whether you are a novice or advanced user, geoprocessing will become an essential part of your daily work with ArcGIS. Geoprocessing provides the necessary data analysis, data management, and data conversion tools for all geographic information system (GIS) software users.
The main purposes of geoprocessing are to allow you to automate your GIS tasks and to perform spatial analysis and modeling. Geoprocessing supports the automation of workflows by providing a set of tools and a mechanism to combine a series of tools in a sequence of operations using models and scripts.
The kinds of tasks to be automated can be mundane, for example, converting data from one format to another; or the tasks can be creative, using a sequence of operations to model and analyze complex spatial relationships. For example, calculating optimum paths through a transportation network, predicting the path of wildfire, analyzing and finding patterns in crime locations, predicting which areas are prone to landslides, or predicting flooding effects of a storm event.
Geoprocessing consists of operators (tools) that operate on the data in ArcGIS (tables, feature classes, rasters, triangulated irregular network [TINs], and so on) and performs necessary tasks for manipulating and analyzing geographic information across a wide range of disciplines. Each geoprocessing tool performs an essential operation on geographic data, such as projecting datasets from one map projection to another, adding fields to a table, or creating buffer zones around features.
ArcGIS includes hundreds of such geoprocessing tools. A geoprocessing tool takes ArcGIS datasets as inputs (such as feature classes, tables, rasters, and computer-aided design [CAD] files), applies an operation against this data, and creates a dataset as output. Tool execution is the basic operation in geoprocessing. 

Creating the geoprocessor object

In .NET, you run a geoprocessing tool by calling the Execute method on the geoprocessor. You can create the geoprocessor in the following two ways:
Using IGeoProcessor of Geoprocessing library
Using the IGeoProcessor2 interface of the GeoProcessor class available in the Geoprocessing type library through the ESRI.ArcGIS.Geoprocessing namespace. See the following code example:
[C#]
IGeoProcessor2 gp=new GeoProcessorClass();
[VB.NET]
Dim gp As IGeoProcessor2=New GeoProcessor
The letter "P" is uppercase in IGeoProcessor2 and GeoProcessorClass.
Using Geoprocessor class of the managed assembly
Using the Geoprocessor class of the Geoprocessor managed assembly (p is lowercase) available through the ESRI.ArcGIS.Geoprocessor namespace. See the following code example:
[C#]
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp=new ESRI.ArcGIS.Geoprocessor.Geoprocessor
    ();
[VB.NET]
Dim gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor=New ESRI.ArcGIS.Geoprocessor.Geoprocessor
The letter "p" is lowercase. This is important in C# as C# is case-sensitive. The GeoProcessor and Geoprocessor is the same in VB .NET as it is not case-sensitive. Therefore, you need to qualify them with the full namespace if you import both  ESRI.ArcGIS.Geoprocessing and ESRI.ArcGIS.Geoprocessor in your project.
The created "gp" object is referred to as the geoprocessor (both g and p are lowercase) throughout the documentation.

Using the geoprocessor object

The created geoprocessor object (gp) has the same methods and properties, no matter what approach you take to create it. The other differences between the two approaches are as follows:
So, which approach is better? In short, both approaches are equally applicable; although, the managed classes have the advantage of being .NET native and you get IntelliSense for tool parameters. The scope is limited to only a subset (although, the most important one) of geoprocessing functionalities. Conversely, the only limitation of using IGeoProcessor.Execute is that you are forced to know the order of a tool's parameters. However, that can be considered a benefit also, for example, the IntelliSense of the managed classes do not show if a parameter is "derived." For more information, see Interpreting a tool reference page.


See Also:

A quick tour of executing tools
Geoprocessing assembly overview
Geoprocessor managed assembly
How to run a geoprocessing tool




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):