McConkey: Chapter 5

This chapter was alright compared to the others but there are definitely a few concepts I do not quite understand yet.

ArcPy is built into ArcGIS Pro if you are using IDLE. Other IDE’s like Spyder requires extra steps to access ArcPY. 

Key Terms:

Class- are used to create objects which have properties and methods

Environment- Hidden parameters that influence how a tool is run

Hard-coded- the parameters are not set as variables but use the values assigned to them directly. 

Namespace- a system to make sure all the names are unique and can be used without any conflicts

nontool function- A function in Python performs a specific task. ArcPy provides several functions that are not tools, otherwise known as nontool functions. Nearly all  geoprocessing tools in ArcGIS Pro or functions in ArcPy, but not all ArcPy functions are geoprocessing tools in ArcGIS Pro.

Package- a collection of modules, functions, and classes that adds functionality to Python

Property- a workspace is an example of a property that an object has

toolbox alias- tools may share the same tool name so they require a specific tool alias when applied in ArcPy (ex. Clip_management)

tool label- a tool name with no spaces (ex. AddField [as in ArcPy])

tool name- a tool label that contains spaces (ex. Add Field [in Data Management toolbox])

factory code (of a coordinate system)/well-known ID (WKID)- A series of numbers used to represent a name. WKIDs are often used for map projections because their names can be written out in different ways but not always be recognized by Python.

Workspace- provides a default location for the files you will be working with, such as inputs and outputs of geoprocessing tools.


Review Questions:

Explain the relationship between the geoprocessing tools in ArcGIS Pro and the functions in ArcPy?

ArcPy must be imported first in order to use its geoprocessing tools. ArcPy makes Python scripting easier and more powerful. 

What exactly is the difference between required and optional parameters of geoprocessing tools, and how does this impact writing code to use these tools in a script?

Required and optional parameters are just as they sound. Required parameters are required for the script to run properly while optional parameters are not. There are a variety of ways to write the optional parameters in your script without them actually doing anything. This can be done by writing “”, “#”, or None in its place. This will leave the optional parameters at their default values.

Give an example of the use of variables for parameters instead of hard-coding values to make your code more versatile?

You could write as follows:

import arcpy

arcpy.env.workspace = “C:/Data”

infc = “streams.shp”

clipfc = “study.shp”

outfc = “results.sph”

arcpy.Clip_analysis(infc, clipfc, outfc)

If you are writing scripts or tools to be shared with others it is wise to use variables instead of hard-coding. Variables also make it easier to reuse part of your code.

Explain some of the uses of the “Result” object: 

ArcPy returns the output of a tool as a Result object. The result object can consist of a string, number, or a Boolean value. (See page 163)

Why are classes used as input parameters for geoprocessing tools?

ArcPy classes are often used as shortcuts for tool parameters that would otherwise have a more complicated equivalent. They are often used to avoid using lengthy strings.

Explain how ArcGIS Pro is licensed and how this impacts handling licensing when writing scripts.

Licensing effects which geoprocessing tools can be used by the user.