- Programming ArcGIS 10.1 with Python Cookbook
- Eric Pimpler
- 671字
- 2021-07-30 17:29:55
Using ArcGIS Desktop help
The ArcGIS Desktop help system is an excellent resource for obtaining information about any available tool. Each tool is described in detail on a unique page. The help system is available through ArcGIS Desktop or online.
Getting ready
In addition to containing basic descriptive information about each tool, the help system also includes information of interest to Python programmers, including syntax and code examples that provide detailed information about how the tool can be used in your scripts. In this recipe, you will learn how to access the ArcGIS Desktop help system to obtain syntax information and code examples.
How to do it...
Follow these steps to learn how to use the ArcGIS Desktop help system to access syntax information about a tool as well as a code example showing how the tool is used in a script.
- If necessary, open ArcMap and select Help | ArcGIS Desktop Help from the main menu.
- Select the Contents tab.
- Select Geoprocessing | Tool reference. The tools are grouped according to toolbox just as they are in ArcToolbox.
- Select Analysis toolbox and then Proximity toolset.
- Click on the Buffer tool. You should see the Buffer tool help displayed, as shown in the following screenshot:
- Scroll down to the Syntax section, as shown in the following screenshot:
- This section defines the syntax for how the tool should be called from your script. In this case, the syntax is as follows:
Buffer_analysis (in_features, out_feature_class, buffer_distance_or_field, {line_side}, {line_end_type}, {dissolve_option}, {dissolve_field})
- Scroll down to the Code Sample section. Here, you will find one or more code samples showing you how the tool can be used in your scripts. I always recommend taking a look at these samples before writing your scripts.
How it works...
The help system for each tool contains several sections including a summary, illustration, usage, syntax, code sample, environments, related topics, and licensing information. As a programmer, you will primarily be interested in the syntax and code sample sections.
When looking at the syntax section, notice that you call each tool using a combination of the name followed by an underscore and finally the alias for the toolbox where the tool resides. We discussed this briefly in a recipe earlier in this chapter.
Tools typically accept one or more parameters, which are passed into the tool inside parentheses. Parameters can be either required or optional. In this case, the Buffer tool includes three required parameters: the input feature, an output feature class, and a distance. Required parameters are listed first and are not enclosed by any special characters. Optional parameters, on the other hand, are enclosed by curly braces and will follow any required parameters. The Buffer tool contains several optional parameters including the line side, line end type, dissolve option, and dissolve field. Notice that each of these parameters is enclosed by curly braces. You do not have to include these parameters when calling a tool for it to execute.
You should also examine the syntax information in greater detail to determine the data-type that should be passed in for each parameter. For example, the buffer_distance_or_field
parameter can accept a data-type that is either a linear unit or a field. Therefore, you can supply a numeric value for this parameter or a Field
object that represents an attribute field containing distance information.
Always review the syntax for each tool before using it in your code to make sure that you have the right parameters in the right order and of the right data type.
I recommend taking a look at the code samples as well since they will frequently give you a starting point for your script. Often you will find that you can copy and paste at least a portion of the sample into your own script and then alter the script to suit your needs. This can make you a more efficient programmer and for learning purposes it is helpful to take a look at other scripts and examine the script line-by-line to determine how the script works.
- Learn ECMAScript(Second Edition)
- HornetQ Messaging Developer’s Guide
- Practical Data Analysis Cookbook
- Reactive Programming with Swift
- 數(shù)據(jù)庫系統(tǒng)原理及MySQL應用教程
- Mastering LibGDX Game Development
- Web程序設計(第二版)
- SQL Server 2016數(shù)據(jù)庫應用與開發(fā)
- Solr Cookbook(Third Edition)
- 輕松上手2D游戲開發(fā):Unity入門
- 創(chuàng)意UI:Photoshop玩轉(zhuǎn)APP設計
- 玩轉(zhuǎn).NET Micro Framework移植:基于STM32F10x處理器
- Hacking Android
- IPython Interactive Computing and Visualization Cookbook
- NGUI for Unity