McConkey: Chapter 6

        Chapter 6 took around an hour to read. It mostly handles how to confirm that data exists, creating lists to see where data is, and creating lists for specific data (ex. Isolating shapefiles). You can also use python scripting to describe the characteristics of a feature class, shapefile, raster, or table. An example of this would be to determine if a shapefile is a polyline through a Describe ( ) function. Using a script to produce a list can help later on when using batch processing. 

Key terms:

System paths – the paths recognized by the Windows operating system

Catalog paths – the paths that only ArcGIS Pro recognizes

List comprehension – used to create lists from existing files in a variety of ways

Wildcard – All functions have a wildcard parameter (*), which defines a name filter. A wildcard is a symbol that represents one or more characters. 

 

What key similarities and differences are there between Describe ( ) and da.Describe ( ) functions?

For the Describe ( ) function, the properties of the object are dynamic. For the da.Describe ( ) function, the keys of the dictionary are dynamic. 

 

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.

 

 

Wade: Chapter 5: Geoprocessing Using Python

Terms

Class: like an outline for creating a new object

Environment: a tool that helps to keep dependencies required by different projects separate

Factory Code:Factory method is a creational design pattern which solves the problem of creating product objects without specifying their concrete classes. Factory Method defines a method, which should be used for creating objects instead of direct constructor call ( new operator).

Function: a block of code that only runs when it is called.

Hard-Coded: A part of a program that has been declared as unchanging

Instance: An individual object of a certain class.

Method: a function that “belongs to” an object.

Namespace: a system that has a unique name for each and every object in Python

Object: Everything is in Python treated as an object, including variable, function, list, tuple, dictionary, set, etc. Every object belongs to its class.

Package: A package is basically a directory with Python files and a file with the name __init__ . py. This means that every directory inside of the Python path, which contains a file named __init__ . py, will be treated as a package by Python.

Property: the main purpose of Property() function is to create property of a class.

Well-known ID (WKID): a unique number assigned to a coordinate system.

Well-known text (WKT): an Open Geospatial Consortium (OGC) standard that is used to represent spatial data in a textual format.

Workspace: supports the embedding and running of Python scripts within a workflow.

 

Review Questions

 

  • Explain some of the uses of the “Result” object. 
    • The result object can be used as an input to another function. The result object also has properties and methods.

 

 

  • Why are classes used as input parameters for geoprocessing tools?
    • Classes are often used as shortcuts for tool parameters that would otherwise have a more complicated equivalent.

 

  • What are some of the typical environments set in a script?

 

      1. ClearEnvironment.
      2. ListEnvironments.
      3. LoadSettings.
      4. ResetEnvironments.
      5. SaveSettings

 

  • Explain how Pro is licensed and how this impacts handling licensing when writing scripts.
    • You must have a license to run geoprocessing tools, which includes running a stand-alone python script that uses these tools. You will receive an error message if you try to run a tool that you do not have a license for, such as Spatial Analyst tools.

McConkey: Chapter 2

This chapter is not too vigorous, but I will definitely have to refer back to it if I want to download Spyder or PyCharm down the line.

Chapter 2 focuses on the various Python editors and what makes each one unique. A Python editor, otherwise known as integrated development environments (IDEs) is used to write, test, and fix code. Python comes with a built-in editor known as IDLE, but Spyder and PyCharm are also recommended IDEs that must be installed separately. This chapter explains how to open and make a shortcut for IDLE as well as directions for installing Spyder and PyCharm, which require some extra steps. The editors may look different but the code works for all of them in the same way. In other words, you do not need to change how you write your code when using another editor. Both Spyder and Python are free and are cross-platform, so they will work on different computer systems. In summary, Spyder is easier to use, but PyCharm has more features within the user interface. (PyCharm also has an optional dark theme.)

Wade: Chapter 4: Learning Python Language Fundamentals

Mack Wade

Chapter 4: Learning Python Language Fundamentals

Terms

Boolean: denoting a system of algebraic notation used to represent logical propositions, especially in computing and electronics.

Boolean Expression: In computer science, a Boolean expression is an expression used in programming languages that produces a Boolean value when evaluated. A Boolean value is either true or false.

Boolean Logic: In mathematics and mathematical logic, Boolean algebra is the branch of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0, respectively.

Boolean OPerator: Boolean Operators are simple words (AND, OR, NOT or AND NOT) used as conjunctions to combine or exclude keywords in a search, resulting in more focused and productive results. This should save time and effort by eliminating inappropriate hits that must be scanned before discarding.

Built in Operator: These operators are used to perform arithmetic computations on their operands. This operator returns the result of adding the two operands (operand1 and operand2).

Camel Case: Camel case is the practice of writing phrases without spaces or punctuation, indicating the separation of words with a single capitalized letter, and the first word starting with either case. Common examples include “iPhone” and “eBay”

Casting: Casting is when you convert a variable value from one type to another.

Comparison Operator: Comparison operators — operators that compare values and return true or false . The operators include: > , < , >= , <= , === , and !== 

Condition: The boolean expression in a conditional statement that determines which branch is executed

Docstring: a string literal specified in source code that is used, like a comment, to document a specific segment of code

Dot Notation: You can access properties on an object by specifying the name of the object, followed by a dot (period) followed by the property name.

Escape character: a character that invokes an alternative interpretation on the following characters in a character sequence.

Float: a data type composed of a number that is not an integer, because it includes a fraction represented in decimal format.

Floor Division: a normal division operation except that it returns the largest possible integer.

F-String: provide a way to embed expressions inside string literals, using a minimal syntax

Immutable: unchanging over time or unable to be changed.

Indexing: a way to refer the individual items within an iterable by its position

Modulus: The Python modulo operator calculates the remainder of dividing two values. This operator is represented by the percentage sign (%). The syntax for the modulo operator is: number1 % number2. The first number is divided by the second then the remainder is returned

Parameter: he variable listed inside the parentheses in the function definition.

Sentry Variable: a variable used in the condition and it is compared to some other value or values

Snake Case: refers to the style of writing in which each space is replaced by an underscore character, and the first letter of each word written in lowercase. It is a commonly used naming convention in computing, for example for variable and subroutine names, and for filenames.

String: an immutable sequence data type. It is the sequence of Unicode characters wrapped inside single, double, or triple quotes

True Division: When dividing something by 1, the answer will always be the original number

Unicode:  Unicode, formally the Unicode Standard, is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world’s writing systems.

Whitespace: characters which are used for spacing, and have an “empty” representation. In the context of python, it means tabs and spaces

Zero-Based Language: Zero-based numbering is a way of numbering in which the initial element of a sequence is assigned the index 0, rather than the index 1 as is typical in everyday non-mathematical or non-programming circumstances

Review Questions

  1. What are the main data types in Python?
    1. The most common ones are float (floating point), int (integer), str (string), bool (Boolean), list, and dict (dictionary). float – used for real numbers. int – used for integers. 
  2. What are unicode strings?
    1. A Unicode string is a sequence of zero or more code points.
  3. What is dot notation?
    1. In general, dot notation tells Python to look inside the space that is before the dot for code to execute. You can use dot notation to access the specific version of a certain function that is defined in a different class or a different module.
  4. Name three methods of string objects in Python.
    1. The static method, the class method, and the instance method.
  5. What are some of the key similarities and differences between lists and tuples in python.
    1. list and tuple are a class of data structure that can store one or more objects or values. A list is used to store multiple items in one variable and can be created using square brackets. Similarly, tuples also can store multiple items in a single variable and can be declared using parentheses.
  6. Describe the use of Boolean expressions to evaluate a condition.
    1. A Boolean expression is a logical statement that is either TRUE or FALSE . Boolean expressions can compare data of any type as long as both parts of the expression have the same basic data type. You can test data to see if it is equal to, greater than, or less than other data.
  7. Describe the steps to create a dictionary and add new items to the dictionary.
    1. A Dictionary can be created by placing a sequence of elements within curly {} braces, separated by ‘comma’. Dictionary holds a pair of values, one being the Key and the other corresponding pair element being its Key:value.
  8. Describe how branching is implemented in Python code.
    1. Branching statements in Python are used to change the normal flow of execution based on some condition. The return branching statement is used to explicitly return from a method. A break branching statement is used to break the loop and transfer control to the line immediately outside of loop. 
  9. What is a compound statement in Python? 
    1. Compound statements are made up of two or more program statements that are executed together. This usually occurs while handling conditions wherein a series of statements are executed when a TRUE or FALSE is evaluated. Compound statements can also be executed within a loop.
  10. Describe the two main looping structures in Python.
    1. “For” and “While” For loops can iterate over a sequence of numbers using the “range” and “xrange” functions. The difference between range and xrange is that the range function returns a new list with numbers of that specified range, whereas xrange returns an iterator, which is more efficient.For loops can iterate over a sequence of numbers using the “range” and “xrange” functions. The difference between range and xrange is that the range function returns a new list with numbers of that specified range, whereas xrange returns an iterator, which is more efficient.
  11. Why should you add comments to your scripts?
    1. Using comments in any script or code is very important to make the script more readable. Comments work as a documentation for the script. The reader can easily understand each step of the script if it is properly commented by the author.

McConkey Chapter 1 Notes

Chapter 1 is a fairly easy read that introduces what Python scripting is and some things that be done with the scripting language. There is some programming terminology but you are given most of the definitions for these terms right away. Python is the programming language used by ArcGIS Pro and there are several reasons for this: it is a simple language and relatively easy to learn, it is free and open-source, and it is cross-platform. Being open-source means that the software can be freely shared as well as scripts written by other people making the Python community strong. Being cross-platform means that Python will work on different platforms such as Windows or macOS.

Python programming is commonly known as a scripting language rather than a programming language. Programming involves building components from scratch and is overall more complicated. Scripting takes already made components and manipulates or relates them to other components often producing an output. An example to book using is changing a line shapefile and generating equally spaced points along the line. You can also use Python scripting to automate tasks. An example given in the book is automating copying and pasting a certain type of shapefiles from a geodatabase with other types of shapefiles. This reduces human error and can be more efficient if there are hundreds of shapefiles. Plus, the script can be saved and used again later, saving more time.

McConkey Set-up Procedures and ArcGIS Pro

So the first thing I did was buy Python Scripting for ArcGIS Pro by Paul A. Zandbergen off of Amazon.  It arrived within a couple of days and I was able to start reading chapter one. After reading chapters 1 and 2 I downloaded ArcGIS Pro with the files provided by Dr. Krygier. The download took around 30 minutes to complete. Once downloaded, I made a new folder and transferred the data to the folder. I then extracted all the data, which took several minutes. Afterwards, I went through the data files and clicked on ones that I thought would open the program. I honestly do not remember what the file was called but eventually I got the software downloaded. It is probably a good idea to add ArcGIS Pro to your taskbar at the bottom of the screen. I did this by right-clicking the application on the desktop and finding the option “Pin to taskbar.”

After I downloaded ArcPro I logged into ESI and looked up training modules for Pro. I was able to find a free one that would take around 3 hours to complete. I downloaded the accompanied data and got started. I did not finish the module, partially due to already being familiar with ArcMap. However, the course was very interesting and I saw how more intuitive Pro is compared to its older counterpart. For instance, you can start a project from several premade templates, which will also automatically make a project folder for various related elements such as geodatabases, layouts, maps, and toolboxes.

Another upgrade is that ArcPro is context-sensitive. When you click on layer of different types, the ribbon above may change showing ways to edit the appearance of that layer or specific tools for that layer type. This makes editing the appearance and labeling layers more convenient. It also makes it easier to familiarize yourself on how the different types of layers can be edited. You can still find tools in the toolbox but now you can put tools into a favorites folder for easier access. This is useful for when you plan on performing the same or similar tasks on a project. Learning a new software is difficult but I believe many of the new features of ArcGIS Pro ultimately make the GIS experience more convenient.

Wade: Chapter 3: Geoprocessing in ArcGIS Pro

Mack Wade

Chapter 3: Geoprocessing in ArcGIS Pro

This chapter was pretty easy to follow along to. I had never used modelbuilder before so that was interesting. 

  • Batch Mode: Batch mode is a network round trip-reduction feature that, as its name implies, batches up data-related operations in order to perform them in more coarse-grained chunks.
  • Batch Processing: Computerized batch processing is the running of “jobs that can run without end user interaction, or can be scheduled to run as resources permit.
  • Current Workspace: Current Workspace—The workspace from which inputs are taken and outputs are placed when running tools. 
  • Geoprocessing: Geoprocessing is a framework and set of tools for processing geographic and related data.
  • Iteration: repetition of a mathematical or computational procedure applied to the result of a previous application, typically as a means of obtaining successively closer approximations to the solution of a problem
  • ModelBuilder: ModelBuilder is a visual programming language for building geoprocessingworkflows

Review Questions

  • Describe some of the general elements of the geoprocessing framework in ArcGIS Pro.
    • A collection of tools, methods to find and execute tools, environment settings and other geoprocessing options that control how tools are run, python window, geoprocessing history 
  • What are the three types of tools in ArcGIS Pro
    • Built tools, script tools, model tools, also system tools and custom tools
  • Explain the difference between system tools and custom tools
    • System tools are created by Esri
    • Custom tools are created by a user or third party
  • What are the strengths and limitations of batch processing in Pro
    • Geoprocessing tools can be run in a batch mode that allows you to run the tool multiple times using many input datasets or different parameter settings. This makes it possible to run a tool many times with very little interaction. 
  • What are some of the similarities and differences between models and tools and script tools in Pro
    • Model tools help you execute multiple tools at the same time
    • script tools help you create your own detailed tool by connecting applications

Wade: Chapter 2: Working With Python Editors

Mack Wade

Chapter 2: Working with Python Editors

Notes

This chapter wasn’t too hard to follow along to. I’m pretty familiar with Pro and some of the terms used. I only followed along with the Python window in Pro. 

Key Terms:

  • Command Line Interface: A command-line interface processes commands to a computer program in the form of lines of text.
  • Dependency: to refer when a piece of software relies on another one. Simply put, if Program A requires Program B to be able to run, Program A is dependent on Program B.
  • Environment: a hardware platform and the operating system that is used in it
  • Interactive Interpreter: Python interpreter runs each line of your code directly. This allows you to use the Python interpreter interactively, simply by typing python at a command prompt.
  • Module: A module is a software component or part of a program that contains one or more routines
  • Package Manager: A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer’s operating system in a consistent manner.
  • Printing: refers to writing text on the screen
  • Prompt: signals where you can type code
  • PyCharm: PyCharm is an integrated development environment used in computer programming
  • Python editor: has a menu-driven interface and tools for organizing and testing Python scripts to make working with Python easier
  • Python environment: A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them. 
  • Python Package manager: Python Package Manager is a Python utility intended to simplify the tasks of locating, installing, upgrading and removing Python packages. It can determine if the most recent version of a software package is installed on a system, and can install or upgrade that package from a local or remote host.
  • Python Shell: Python provides a Python Shell, which is used to execute a single Python command and display the result.

 

Review Questions

  • Which Python editor comes installed with every version of Python? 
    • IDLE comes installed with every version of python. 
  • What are some of the recommended Python editors to work with in Pro?
    • Spyder, Pycharm
  • What is syntax highlighting?
    • Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms.
  • What is the file extension for a Python script file?
    • .py 
  • How do you open the Python window in Pro?
    • Analysis Tab > Python > Python window
  • What are some typical examples of autocompletion prompts in the python window, and how do they help you write proper code
    • They assist in reducing the amount of writing you need to do

Wade: Chapter 1: Introducing Python

 

Mack Wade

Chapter 1: Introducing Python

Notes

  • Python is a free + open source software (FOSS)
  • Programming is building elements from scratch
  • Scripting is the glue that allows elements to work together
  • Python is both a scripting and programming language
  • Python is the preferred programming language for ArcGIS Pro (Pro uses Python 3)

Terms

  • Back Porting – When a software patch or update is taken from a recent software version and approved to an older version of the same software
  • Backward Compatibility – a property of a system, product, or technology that allows for interoperability with an older legacy system, or for input designed for such a system
  • Cross Platform – Any software application that works on multiple operating systems
  • Interpreted Language – A programming language which are generally interpreted, without compiling a program into a machine
  • Object Oriented – A methodology which enables a system to be modeled as a set of objects which can be controlled and manipulated in a modular manner
  • Object Oriented Programming (OOP) – A programming paradigm that relies on the concept of classes and objects
  • Syntax – The set of rules that defines the conditions of symbols that are considered to be correctly structured statements or expressions in that language

 

Review Questions

  • What are some of the key features of Python that make it suitable as a scripting language to work with ArcGIS Pro? 
    • Python is the preferred language for Pro, and has its own module, ArcPy,  that allows python to translate GIS functions. You can also run Python on the Python window in Pro that allows you to directly run code and see results in the map. 
  • What does it mean that Python is an interpreted language? 
    • Python is called an interpreted language because it goes through an interpreter, which turns code into the language understood by the computer’s processor
  • What are some of the differences between scripting and programming?
    • Scripting
      • To automate certain tasks in a program
      • Extracting info from a data set
      • Less code intensive as compared to traditional programming languages
    • Programming
      • Typically run inside a parent program 
      • More compatible while integrating code with mathematical models
  • Which Version of Python is used with ArcGIS Pro?
    • Python 3
  • What are some of the reasons to invest time and effort into learning Python?
    • Python is very easy to learn as a beginner. Python can also automate tasks that would otherwise be performed manually and would take up time.