GIS Logo GSP 118 (318): GIS Programming

Course Outline for “GIS Programming in Python”

In Review

Introduction

This document defines the initial outline for the new geo 599 class, GIS Programming in Python.  This document is a work in progress and will change throughout the first quarter the class is taught and will then be updated as new technical developments or student needs emerge.

Each of the sections below begins with the learning objectives, then the format for learning activities, and finally the labs the students will complete and turn-in.  This class focuses on skills so discussion is at a minimum.  Most of the activities will be either lectures or hands-on where the students follow the instructors actions on the computer.  The question marks (?) indicate items that are still being decided upon.

Week 1: Getting started with Python

- Objectives:
                - Understand connection between ArcGIS and Python
                - Get started writing Python code in the Wing IDE
                - Learn to generate series of numbers from Python
- Activities:
                - Hands-on: Going from model builder to Python to the Wing IDE
                - Hands-on: Introduction to the Wing IDE and printing from Python scripts
                - Hands-on: Generating series of values from Python
                - Hands-on: Generating random numbers in Python
                - Hands-on: Creating histograms in Python
- Readings:
                - Extending ArcGIS With Python
                - Wing IDE Tutorial: 1.1.0, 1.1.1, 1.1.4, and 1.1.5 (available in the help menu in the Wing IDE
                - The Python Tutorial (http://docs.python.org/tutorial/)
                                - Informal into to Python: Sections 3 through 3.1.2 and 3.2
- Optional Readings:
                - Beginner’s Guide to Python (http://wiki.python.org/moin/BeginnersGuide)
                - Python for Non Programmers (http://wiki.python.org/moin/BeginnersGuide/NonProgrammers)
- Lab:
                - Using Model Builder to create Python scripts
                                - Turn in: Documented model builder model and Python code
- Write values to the Debug I/O window and copy into a spreadsheet program (i.e. Excel)
                - Exponential
                - Logistic
                - Something harder (Lotka–Volterra?)
                - Turn in:
- Documented Python program that generates two unique series of numbers
- Excel file with the two series overlaid in a chart
- Generating random numbers
                - Create histogram, plot in Excel
                - Turn in (extra credit):
                                - Program that generates a series of random numbers of a given distribution
                                - Excel file with the data plotted as a histogram

Week 2: How computers work with numbers and creating synthetic data


- Objectives:
                - Learn how computers represent numbers
                - Learn how text files can be accessed through Python
- Use Python to create tab-delimited text files and ASCII Grid files from Python
- Activities:
                - Hands-on: How computers work
                                - Mathematical operations and numeric precision
                                - Strings
                                - Boolean logic, “if” statements
                                - “for” statements
                - Hands on: Writing tab-delimited files
- Lecture: ASCII grid file format
- Hands on: Writing ASCII grid files
- Readings:
                - How computers work (from Jim)
                - Simple File I/O (from Jim)
                - Esri Grid (http://en.wikipedia.org/wiki/Esri_grid)
- Labs:
                - Write a tab-delimited file and load into Arc
                                - Turn in:
                                                - Documented Python script
                                                - Final text file
                - Write an ASCII grid file and load into Arc
                                - Turn in:
                                                - Documented Python Script
                                                - Final ASCII Grid file

Week 3: Reformatting data with Python

- Objectives:
                - Learn to parse large text files to extract desired data
                - Learn to reformat text files of data
- Activities:
                - Lectures: How computers work
                                - Dates
                - Hands-on: Reading files
                - Hands-on: Data on the internet and problems with formats
- Readings
                - The Python Tutorial (http://docs.python.org/tutorial/)
                                - Dates and times : Section 10.8
                - Python Library Reference (http://docs.python.org/py3k/library/)
                                - Section 7 Data Types, especially date time
- Labs:
- Handling files with large amounts of data
                - Turn in:
                                - Documented Python script to parse a large file
                                - Extracted data
                - Examples:
- Global city file: parse for largest cities
                                - AKN data
-  Reformatting data files
                - Turn in:
                                - Documented Python script to reformat a file
                                - File with extracted data
                - Examples:
                                                - HUC data
- Tree ring data: download, parse, and load

Week 4: Accessing data on the Internet and when to use different data structures

- Objectives
                - Understand the available data structures in Python and when to use them
                - Learn to access REST-based web service data on the Internet
                - Learn to parse XML files
                - Learn to write KML files
- Activities:
                - Hands-on: Comparing Arrays and Lists
                - Hands-on: Accessing a web service
                - Lecture: Introduction to the Extensible Markup Language (XML)
                - Hands-on: Parsing XML, storing data in arrays, and writing it to a tab-delimited file
                - Hands-on: Writing KML files from Python (see KML reference online)
- Labs
                - Access a web service and parse to a tab-delimited file
- Load the file into Arc
- Which service: GBIF?,  GISIN? Other?

Week 5: Accessing ArcGIS from Python

- Objectives
                - Learn to load Python libraries
                - Understand how ArcGIS (arcpy) can be used from Python to process files
                - Learn to create functions
- Activities
                - Lecture: arcpy functions
                - Hands-on: creating a Python script with multiple calls to ArcGIS functions
                - Hands-on: batch processing with Python
                - Hands-on: Defining functions
- Labs
- Convert and mosaic rasters
                - Documented Python script that mosaics and tiles all the files in a folder:
                                - Converts from some file format to a GRID file
                                - Converts the data type to ?
                                - Mosaics and crops the tiles
                                - Saves a new file format
                - Turn-in:
                                - Documented Python script

Week 6: More on ArcGIS and Python

- Objectives
                - Learn about accessing additional capabilities in ArcGIS  
                                - Needs to be defined based on class input
                                - Kuuipo – ideas here?
                                - GeoDatabase?
                - Learn to use Object Oriented Programming to organize code
- Activities:
                - Lecture: Introduction to Object Oriented Programming
                - Hands-on: Encapsulating code in classes, adapter layers for ArcGIS
                - Hands-on: Accessing GeoDatabases from Python?
- Labs:
                - Create a class to access a GeoDatabase?
                - Something else based on class input?

Week 7: User Interfaces (UI) – Command Line and Graphic User Interface (GUI)

- Objectives
                - Learn when to use command line or a GUI
                - Understand how to implement UI elements
- Activities:
                - Hands-on: Getting parameters from a command line
                - Hands-on: Adding user input to a command line
- Hands-on: GUI
                                - Error handling
                                - Messages
                                - Dialog boxes
                                - “Modeless” interface?
- Labs
                - Command line program with in-line parameters
                - Command line program that takes user input (selection from a menu)
                - Program with a GUI?
                                - Utility with one dialog?

Week 8: Other Packages
- Objectives
                - Learn about the other libraries that are available for Python
- Activities:
- Lecture: Finding and evaluating other libraries
- Hands-on: Useful libraries: http://wiki.python.org/moin/UsefulModules
                                - The Python standard library
                                - GIS: Googlemaps, geopy, etc.
                                - Python Imaging Library
                                - The Java connection?
                                - Scientific: R, Plotting, etc.
- Reading:
                - Python useful modules (http://wiki.python.org/moin/UsefulModules)
- Lab:
                - Find and use one or more of the libraries above in a program you define?
                                - This could be the start of an individual or group project(?)
                                - Turn-in:
                                                - One-page evaluation of a Python library
                                                - Documented Python program

Week 9: Creating larger projects

- Objectives
                - Learn when and how to use software lifecycles to ensure project success
                - Find out how to manage errors in Python programs
- Activities:
                - Lecture: The software development process (Power Point)
                                - Appropriate software documentation: requirements, design, tech notes, QAQC
                - Hands-on: Error handling
- Labs
                - Define and create a program with appropriate documentation
                                - Give them until the final to create and present their final project?

Week 10

- Objectives:
                - Learn how to get help outside classrooms
                - There is some pad here to address additional topics or to catch up
- Activities:
                - Lecture: Matt to visit on the Python user’s group?
                - Lecture: Visitor from commercial and/or government?
- Labs:
                - From previous week?

Other possible topics:

- DayMet w/NetCDF – convert to BSQ to load in Arc?
- Animation?
- SQL Database?
- HTML?
                - Forms?
                - SQL interaction?
- Log files