GP学习(二)—Executing tools and Accesubg licensing0
2016-07-15 15:14
696 查看
声明:仅做自己学习整理用,内容拷贝自ArcEngine SDK开发文档
Creating the geoprocessor object
Using the geoprocessor object
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.
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#]
[C#]
Setting up and running a geoprocessing tool. For more information, see How
to run a geoprocessing tool.
Handling errors. For more information, see Working
with result objects.
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.
An ArcGIS Desktop license is required to execute a tool in a program. Tools from ArcGIS extensions, such as ArcGIS Spatial Analyst, require an additional license for that extension. If the necessary licenses are
not available, a tool fails and returns the appropriate error messages.
In ArcGIS 10, you need to set the product that will execute the code by the RuntimeManager. Add ESRI.ArcGIS.Version to your project as a reference. However, you don't need to add the namespace to your code with
the using keyword.
When using an ArcView or ArcEditor license, a program must explicitly use AoIntialize,
and the product must be set to ArcView or ArcEditor, or the program fails. By default, the geoprocessor always assumes an ArcInfo license is required for execution of a tool. See the following code example:
[C#]
|
In this topic
About roadmap to executing toolsCreating the geoprocessor object
Using the geoprocessor object
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 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();
[C#]
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor ();
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:Setting up and running a geoprocessing tool. For more information, see How
to run a geoprocessing tool.
Handling errors. For more information, see Working
with result objects.
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.
|
About accessing licensing and extensions for the geoprocessor
An ArcGIS Desktop license is required to execute a tool in a program. Tools from ArcGIS extensions, such as ArcGIS Spatial Analyst, require an additional license for that extension. If the necessary licenses arenot available, a tool fails and returns the appropriate error messages.
In ArcGIS 10, you need to set the product that will execute the code by the RuntimeManager. Add ESRI.ArcGIS.Version to your project as a reference. However, you don't need to add the namespace to your code with
the using keyword.
When using an ArcView or ArcEditor license, a program must explicitly use AoIntialize,
and the product must be set to ArcView or ArcEditor, or the program fails. By default, the geoprocessor always assumes an ArcInfo license is required for execution of a tool. See the following code example:
[C#]
static void Main(string[] args) { // Add runtime management ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop); //Initialize the application. esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable; IAoInitialize m_AoInitialize = new AoInitializeClass(); licenseStatus = m_AoInitialize.Initialize (esriLicenseProductCode.esriLicenseProductCodeArcInfo); licenseStatus = m_AoInitialize.CheckOutExtension (esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst); // Initialize the geoprocessor. Geoprocessor gp = new Geoprocessor(); Slope tSlope = new Slope(); tSlope.in_raster = @"E:\Data\demlatgrd"; tSlope.out_raster = @"E:\Data\aspect03"; gp.Execute(tSlope, null); licenseStatus = m_AoInitialize.CheckInExtension (esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst); m_AoInitialize.Shutdown(); m_AoInitialize = null; }
相关文章推荐
- BGP邻居协商过程
- BGP边界网关协议
- 基于ArcEngine+C#开发的空间数据管理平台架构设计及功能说明
- LP与GP的区别
- TIPTOP GP5.1 实现链接网页方法 ui.Interface.frontCall
- ArcEngine实现坐标转换和投影
- AE开发之PageLayoutControl
- AE开发之IMapFrame接口
- TOCControl代码实现图层名可编辑
- AE开发之之ILayer接口
- Dynamics GP report Note
- ArcEngine 专题图关键代码
- IDW Spatial Analyst(ESRI.ArcGIS.SpatialAnalystTools)ArcEngine中反距离加权插值方法
- ESRI.ArcGIS.RuntimeManager.Bind返回false解决方法
- AE各种小知识点
- ICoverageAnnotationFeature注记字符串内容获取
- arcengine镶嵌数据集的基本操作(C#)
- ArcEngine报0x80040228的错误
- GA/GP中的适应度函数