Announcing the Python for ArcGIS Course

Harrisburg Area Community College Lancaster Campus

Last summer was a busy and exciting season of life.  My wife and I welcomed our third child into the world, and I had the opportunity to develop the Python for ArcGIS course for Harrisburg Area Community College.  This self-paced online course is now available to purchase.

The course consists of video lessons, exercises, and recommended articles to read.  It covers the basics of Python, and provides a deeper look into how to automate tasks in ArcGIS using the ArcPy site package.  It covers creating and editing datasets, working with map documents and layers, and teaches you how to build a custom geoprocessing tool. The cost for the course if $499.

If you have been wanting to learn Python and ArcPy, or simply want to learn how to automate tasks and workflows in ArcGIS, then please consider purchasing the course.  So you have a better idea if this course is right for you, I’m going to provide you with three things:

  1. An outline of the topics covered in the course
  2. A sample lesson video (finding broken data sources in a map document)
  3. A sample lesson script (finding broken data sources in a map document)

You can purchase the course at this website.

Course Outline

  • Introduction
    • Required Software
    • Helpful Resources
    • Introduction to Python
  • Unit 1 – Programming Fundamentals 1
    • Data Types
      • Strings
      • Numbers
      • Lists, Tuples, Dictionaries
    • Functions
    • Creating and Writing to a Text File
    • Exercise 1
  • Unit 2 – Programming Fundamentals 2
    • Modules
    • Conditional Statements
    • Loops
    • Exercise 2
    • Classes
    • Error Handling
    • Exercise 3
  • Unit 3 – Introduction to ArcPy
    • Introduction to ArcPy
    • ArcPy Utility Functions
    • Describing Data
    • Exercise 4
  • Unit 4 – Data Access and Creation with Geodatabase
    • Creating Geodatabases and Datasets
    • Exercise 5
    • Accessing Data with Cursors
    • Exercise 6
  • Unit 5 – Working with Geometry and Selections
    • Geometry
    • Exercise 7
    • Selections
    • Exercise 8
  • Unit 6 – Working with Maps, Layers and Layer-Rendering
    • Maps
    • Layers
    • Exercise 9
  • Unit 7 – Working with Map Layouts
    • Exporting and Printing Maps
    • Modifying Layout Elements
    • Exercise 10
  • Unit 8 – Building a Custom Geoprocessing Tool
    • Introduction
    • Building a Custom Geoprocessing Tool
    • Capstone Project
  • Next Steps

Sample Video

Sample Script

# Name: Lesson 24 – Working With Multiple Maps In A Directory,
# Geospatial Programming
# Author: Patrick McKinney, Harrisburg Area Community College
# Created: 6/13/17
# Description: sample script for looping through a folder (directory)
# and listing broken data sources in each map document (.mxd)
# file within the folder
# Copyright: Harrisburg Area Community College, 2017#
import arcpy, os, sys
# placeholder for text for text file
logMsg = ''
# text file to write report information to
logFile = r'C:\[path]\[to]\[folder]\GIS Python Course\Lessons\Lesson Scripts\Unit 6\Broken Data Sources Report.txt'
# directory to search within for broken data sources in map documents (.mxd)
directory = r'C:\[path]\[to]\[folder]\GIS Python Course\Lessons\Lesson Scripts\Unit 6\Maps'
# add message
logMsg += 'Finding broken data sources for map documents (.mxd) in {}\n'.format(directory)
# loop through files in directory
# os module –
# os.listdir returns a list containing the names of the entries in the directory
for fileName in os.listdir(directory):
# fullPath is set to the path and file name for each file in directory
# i.e., C:\[path]\[to]\[folder]\GIS Python Course\Lessons\Lesson Scripts\Unit 6\Maps\Transportation Map.mxd
fullPath = os.path.join(directory, fileName)
# Returns True if path is an existing regular file
if os.path.isfile(fullPath):
# Split the pathname path into a pair (root, ext) such that root + ext == path
# get the extension for the file
basename, extension = os.path.splitext(fullPath)
# if the file is a map document (.mxd), execute code to find broken data sources
if extension == ".mxd":
# add message
logMsg += '\nListing of broken data sources for {}:\n'.format(fileName)
# variable for map document
mxd = arcpy.mapping.MapDocument(fullPath)
# get a list of broken data sources in mapd document
brknList = arcpy.mapping.ListBrokenDataSources(mxd)
# test if there are any broken data sources
if len(brknList) == 0: # condition for no broken data sources
logMsg += '\n\tThere are no broken data sources in this map\n'
else: # condition for broken data sources
# loop through list of broken data layers and write the name of the layer
for brknItem in brknList:
logMsg += '\n\t{}\n'.format(
# end for broken data sources list
# add spacer
logMsg += '\n'
logMsg += '*' * 50
logMsg += '\n'
# end if for mxd file type
# end if for files within directory
# end for files/folders within directory
# handle error outside of Python system with Environment Error
except EnvironmentError as e:
# Store information about the error
tbE = sys.exc_info()[2]
# write the line number the error occured
logMsg += 'Failed at Line %i \n' % tbE.tb_lineno
# write the error message
logMsg += '\nError: {}\n'.format(str(e))
# Exception error
except Exception as e:
# Store information about the error
tbE = sys.exc_info()[2]
# write the line number the error occured
logMsg += 'Failed at Line %i \n' % tbE.tb_lineno
# write the error message
logMsg += '\nError: {}\n'.format(e.message)
# clean up operations
# del mxd to release locks
if mxd:
del mxd
# write information to text file
with open(logFile,'w') as f:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s