GP学习(二)—Executing tools and Accesubg licensing0
来源:互联网 发布:去掉淘宝客链接 编辑:程序博客网 时间:2024/05/17 00:59
In this topic
- About roadmap to executing tools
- Creating 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:
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 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#]
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;}
0 0
- GP学习(二)—Executing tools and Accesubg licensing0
- GP规范学习(二)
- GP学习(六)—Creating geodatabase and connecting geodatabase
- ArcGIS API For Javascript GP工具 Printing Tools导出地图或者打印地图(二):GP 服务Printing Tools
- GP学习整理(一)—Geoprocessing assembly and Geoprocessor managed assembly
- GP学习(九)—Working with geodatabases and the geoprocessor
- GP学习(八)—How to access a raster dataset and to create a raster dataset
- pycaffe学习之(二)tools.py
- GP规范学习(一)
- GP规范学习(三)
- ArcGIS API For Javascript GP工具 Printing Tools导出地图或者打印地图(一):GP 服务Printing Tools
- Development environment and tools of device driver(二)
- GP学习(五)—ArcGIS Toolbox Reference dialog box
- GP学习(七)—Accessing raster workspaces
- Forking and executing process
- 学习笔记之ArcGIS Engine调用自定义GP服务(二)
- Tools(二)——BytesAdd
- GP技术的展望——道生一,一生二
- Android 开发你需要了解的 Gradle 配置
- Git版本控制
- 1016-Prime Ring Problem,素数环,深搜!
- Android学QQ聊天列表展示ListView
- 图片下拉放大 导航栏下拉隐藏 上拉出现
- GP学习(二)—Executing tools and Accesubg licensing0
- 【BZOJ1968】[Ahoi2005]COMMON 约数研究【数论】
- 8. String to Integer (atoi)
- 三、文件搜索命令【基础篇】
- 将HTML5封装成android应用APK文件的几种方法
- Android开发艺术探索——IPC之Messenger、AIDL
- gridview 点击行变颜色
- JAVA文件操作大全(5)
- 浅谈Java的反射机制