Python & GIS - Section Overview
Introduction
With the fundamentals of coding in Python starting to settle in, we now return to geospatial analysis. This effort begins with a look at how we can extend Python with Python packages - modules developed by others that bring new functionality to our coding environment. Among those packages is ArcPy, written by the folks at ESRI to give us pretty much the entire functionality of ArcGIS Pro from Python. We spend a bit of time learning what we can do with the ArcPy package and how it’s done. And in doing so, we learn quite a bit about how Python is extended using packages - and the limitless possibilities this opens us up to.
Demo: Hurricane Mapper – In Python: HurricaneMapperPY.zip
Resource: https://www.esri.com/en-us/arcgis/products/arcgis-python-libraries/libraries/arcpy
Section organization & learning outcomes
Section | Learning Objectives |
---|---|
Python environments & extending Python |
♦ Explain what Python modules & packages are and how they are used ♦ Contrast built-in vs 3rd party modules & packages ♦ Describe: “Anaconda”, “Miniconda”, and “Enthought” distributions… |
Conda & Coding Environments | ♦ Explain what a Python environment is and why they are needed - Create new/cloned Conda environments using Conda - Set a particular Conda environment to be the default environment ♦ Locate and install packages into a Conda environment - Finding packages and package documentation via package repositories - Add packages to a Conda environment via conda and via pip ♦ Import packages and package components into a Python script |
Running Geoprocessing tools in Python | ♦ Access the Python command prompt in ArcGIS Pro ♦ Run a geoprocessing tool from the Python command prompt in ArcGIS Pro ♦ Run a geoprocessing tool from within VS Code ♦ Locate the proper Python syntax for a tool within the ArcGIS Pro help ♦ Identify which parameters are required and which are optional for a tool ♦ Explain how spatial datasets are referenced in geoprocessing tools (i.e. as strings) ♦ Set the tool output as a variable, and use that output in a subsequent tool |
Geospatial Workflows with ArcPy | ♦ Importing the ArcPy package into your coding environment ♦ Setting variables, including pathnames to spatial datasets ♦ Working with geoprocessing tool outputs ♦ Executing geoprocessing tools in sequence ♦ Using messaging and viewing code outputs |
ArcPy Functions, Classes, & Modules | ♦ Describe what Python functions and classes are and how they are used in code ♦ Access lists of ArcPy functions and classes in the ArcGIS Pro documentation ♦ Access the list of ArcPy modules and understand why and how they’re used |
**Creating Script Tools ** | ♦ Enabling input parameters to your Python scripts ♦ Creating Script based tools in ArcGIS Pro ♦ Generate messages in your code that are sent back to ArcGIS Pro ♦ Handing script output with in your ArcGIS Pro script-based tools |