Chapter 3:
Reading Notes:
- I donât think that I have ever searched for a tool using the analysis gallery. I usually always go straight to the geoprocessing pane, which seems more robust anyway.
- Built-in tools: Built using ArcObjects and compiled in PL like C++.
- Script Tools: Python Scripts are accessible from the dialog box.
- Model Tools: Created using model builder
- System vs. Custom Tools
- Current vs. Scratch workplace: Current specifies where inputs and outputs are placed and Scratch is used for intermediate data in model and script tools.
- Environments can be set for the application, the individual tool, the properties of a model, or a script.
- Data Connectors, Environment Connectors, Pre-Condition Connectors; and Feedback Connectors
- You can schedule a script to be run at a certain time.Â
Answers to Review Questions:
- The geoprocessing framework includes toolsets and toolboxes, the ability to search and run tools, environment settings, and parameters, dialog boxes for controlling and executing tools, ModelBuilder (a point + click visual programming language for sequence tools), a Python window, geoprocessing history and lots, and methods for creating python scripts.
- The three types of tools are built-in tools, script tools, and model tools.Â
- System tools are installed as a part of the ArcGIS Pro Software and created by ESRI. Most system tools are built-in, but some are scripts. Custom tools are created by a user or obtained by a 3rd party and usually consist of script and model tools.
- Different environments include: Workspace defines the path of where your datasets are located and where your inputs are and outputs will be. There are also settings for specific data types and functions as well.
- The limitations of batch processing are that filling out the tool can take some time and the tool does not execute faster than normal. However, the strengths are that once you have populated the batch tool it can run multiple times without user input which can be nice for repetition of a task (for example, clipping multiple layers to the same extent).Â
- Dynamic naming allows you to create a unique name for each output layer in batch processing. %Name% is used to take the first part of a layer name and create the output name. Without this step, the file would be continually overwritten. The same process could be done for a path and other output elements.Â
- ModelBuilder requires no programming experience and has little syntax. Scripting has some functionality for lower-level tasks and more advanced programming logic that Model Builder does not. Scripting can also be used to combine applications and can stand alone outside of ArcGIS Pro. The two are similar because there are many geoprocessing workflows that work in both ModelBuilder and Scripting.
- You may choose a script workflow instead of a model for a lower-level task or a more advanced function/extension with additional packages that can only be done in scripting. Additionally, scripting allows for the use of other software like Excel or R as well. Then finally, as mentioned above, scripts can be run and stand-alone outside of ArcGIS Pro.Â
- I am honestly not 100% sure if this is what this question is asking, but to automate workflows you can run Python code in ArcGISâs Python editor or use an external editor like IDLE or PyCharm.
Chapter 4:
Reading Notes:
- Immutable vs. mutable
- I have never used a tuple before so I looked it up. Itâs basically a list but you cannot edit its contents.Â
- The most important statements in a programming language are statements that assign values to variables.
- Every object has a value, a unique identifier, and a type.
- Methods are functions coupled to an object like: <object>.<method>(<arguments>)
- F-strings example: f”The temperature is {temp} degreesâ
- Pairs are also referred to as items in the dictionary
- Set is another datatype to organize elements. It is an unordered collection without duplicates and the elements are enclosed with curly braces. Elements of a set must be immutable.
- input() function gets user input
Answers to Review Questions:
- The main data types are strings, integers, float, and Boolean. Lists, tuples, and dictionaries are more complex data types. Strings, lists, and tuples are sequences. Strings, numbers, and tuples are immutable because you can replace them with new values, but not modify them. Lists and dictionaries are mutable.
- True division is a floating point division where the result of division is reported as a decimal even if the numerator and denominator are integers. In floor division you use the // symbol and the division is truncated to zero decimal points, except for with negative numbers where the result is rounded up (really down) to the nearest whole number.Â
- Dynamic assignment of the variable means that the type of your variable will be automatically inferred based on whatever values you assign to it.Â
- variable_name1 and variablename2 would be examples of good variable names because they consist of only letters, digits, and underscores and they donât include Python keywords or variable names. In a real scenario, these should also be more descriptive of what the variable represents like count or my_raster.
- An expression comes from literal values using operators and functions, but a statement is an instruction that tells the computer to do something.Â
- Quotation marks are used to denote something as a string in Python. Double and single quotation marks can be used interchangeably.Â
- Unicode strings are strings stored in characters of the Unicode system which is designed to represent every character from every language. Because of this, you can work with many different languages in Python.Â
- Five built-in Python functions â #1: print(x) would print the contents of the variable x. #2: id(x) would return the unique identifier of the variable x. #3: type(x) would return the object type of the variable x. #4: abs(x) would return the absolute value of the numeric variable x. #5: round (x, n) would round the float variable x off to n number of digits.
- Dot notion may look something like this <object>.<method>(<arguments>) and it is when the object is written before the period with the method following. It shows that whatever is after the period belongs to the object before the period.Â
- Forward indexing will assign elements an index from first to last starting with 0. Reverse indexing will assign elements an index from last to first starting with -1.
- Three methods of string objects â #1: join() method given a list of elements will join them into a single string. #2: strip() method will remove any of the given characters in the argument from the string no matter what order they are in. #3: replace() method will replace one substring with another everywhere it occurs.
- Lists and Tuples are generally the same except that you can modify a list while tuples are immutable and the sequence and elements cannot be modified.
- A Boolean is used to evaluate if an expression is either true or false.Â
- To create a dictionary you would populate it as follows: dictionaryname = { âKeyâ : âValueâ, âKey2â : âValue2â, âKey3â : âValue3â } You could also create an empty dictionary by not putting anything in the brackets. To add an element you would do as follows: dictionaryname[âKey4â] = âValue4â.
- You should avoid backslashes because they are used as an escape character in Python.Â
- Branching is kind of like a chose-your-adventure situation in the sense that you just need to decide to take one path or another. Typically this means using if statements.Â
- A compound statement is a block that contains multiple statements and statements that determine when other statements will be executed like if, for, while, try, and with.
- Two main loop structures: A while looping structure runs the other statements within the block while the argument given in the while statement evaluates true. Then there is a for loop which typically runs for the duration of a sequence.Â
- You can use a backslash as a line continuation, or (), [], and {} as an implied line continuation to improve readability for long lines of code.Â
- Comments provide information and descriptions about your script that can help you remember and others understand why the script was created.
Chapter 5:
Reading Notes:
- ArcPy is organized into modules, functions, and classes
- Workspace is your default location for files and can be set in a script
- Good practice not to add extra spaces
- Quotation marks are always straight in Python
- Parameters have a name, type, direction, and required value
- Non-tool functions are available only in ArcPy
- Environments are set as properties of the env class
- All functions have a reference/help page that includes sample code, syntax, and explanations of each parameter.
Answers to Review Questions:
- Geoprocessing tools in ArcGIS Pro can all be accessed through ArcPy. To reference a tool its tool name is often the same as the tool label in ArcGIS Pro without spaces. To reference a tool you would also need to include its toolbox alias.
- Required parameters must be specified for a tool to run. Optional parameters are just as they sound, optional, and are usually indicated in documentation by curly brackets. This affects script writing because parameters must be specified in the order listed in the tool documentation. You can specify the name of a parameter or fill its spot with ââ or # when not defining all of the optional parameters.Â
- An example of using variables instead of hard-coded values as parameters would be: arcpy.Clip_analysis(input_file, clip_file, output_file).
- The result object can be used as input for another function as it may contain the path to a dataset, it may also return a string, number, or Boolean values. The result objects will also include messages and parameters based on the tool run.Â
- Classes are used as input parameters as a shortcut that would often be much more complicated. This helps in scenarios where parameters cannot be defined by just a simple string like coordinate systems for example.Â
- To reference a coordinate system you can use arcpy.Describe(), arcpy.da.Describe(), use the name of the coordinate system (ex: arcpy.SpatialReference(“NAD 1983 StatePlane Texas Central FIPS Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4203 (US Feet)â), or using the factory code/well-known id (ex: arcpy.SpatialReference(2277)).Â
- Some typical environments set in a script are the workspace (ex: arcpy.env.workspace = âC:/Dataâ), the cell size (ex: arcpy.env.cellSize = 30), and allowing overwriting (ex: arcpy.env.overwriteOutput = True).Â
- You can obtain a meaningful message by using arcpy.GetMessages(), which is typically the most useful and will give you a list of messages. arcpy.GetMessageCount() will allow you to obtain the number of total messages and can be useful for viewing the last message. Finally, arcpy.GetMaxSeverity() will return a severity level indicating an information, warning, or error message.Â
- ArcGIS Pro is licensed with a Named User license, a Single Use license, and a Concurrent Use license. Available products may vary based on the user account. Scripts will not run and extensions using ArcPy cannot be checked out if no license is available.