官术网_书友最值得收藏!

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.

  1. If necessary, open ArcMap and select Help | ArcGIS Desktop Help from the main menu.
  2. Select the Contents tab.
  3. Select Geoprocessing | Tool reference. The tools are grouped according to toolbox just as they are in ArcToolbox.
  4. Select Analysis toolbox and then Proximity toolset.
  5. Click on the Buffer tool. You should see the Buffer tool help displayed, as shown in the following screenshot:
    How to do it...
  6. Scroll down to the Syntax section, as shown in the following screenshot:
    How to do it...
  7. 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})
  8. 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.

主站蜘蛛池模板: 文昌市| 武夷山市| 临漳县| 益阳市| 新津县| 康平县| 淮阳县| 黔江区| 伊宁县| 拜泉县| 利津县| 县级市| 轮台县| 逊克县| 延寿县| 大埔县| 常宁市| 新乡县| 吉水县| 南岸区| 荣成市| 平果县| 潮安县| 兖州市| 安溪县| 翁源县| 九江市| 陵水| 迭部县| 汶川县| 平塘县| 惠安县| 鸡西市| 龙陵县| 石狮市| 资阳市| 临城县| 和平县| 镇巴县| 大田县| 宁城县|