GIS Programming Fundamentals
This course explains principles, syntax, and language elements associated with creating and running Python and Visual Basic for Applications (VBA) programs. Python scripting is used to efficiently process and filter raw text, csv, and Excel data and perform batch geoprocessing on GIS data. VBA programs add buttons to ArcGIS applications and manipulate map elements. Assignments use Python, ArcGIS, and VBA. Teaching techniques incorporate hands-on learning in a stimulating, interactive classroom environment. Students completing this course will be armed to streamline GIS work-flow and build graphical GIS user interfaces.
Course Objectives:
Use scripting to preprocess data, perform geoprocessing on distributed files, and generally automate repetitive tasks to enhance workflow and build customized Arc user interfaces for geoprocessing. This includes executing stand-alone scripts, incorporating scripts into Modelbuilder models, and calling scripts from VBA applications. The VBA topics include building interfaces for Arc user interaction (adding buttons to toolbars, create dialog boxes, etc. ) and performing fundamental actions such as capturing user input and modifying map layers.
Sample student projects:
| Proportional Attribute Aggregator Tool - Jeff Essic** |
Often people seeking demographic data (population, household numbers, income, etc.) want to know about the demographic profile within a certain distance radius of a set location. Or, they may want demographic data for a particular distinctly defined area. Both of these cases (a buffer or an irregular polygon) have typically involved selecting the Census or other demographic boundary data available for the area of interest, and summarizing as best as possible. The demographic data polygons and study area polygons seldom align. This tool allows the user to overlay a set of polygons and determine the proportional Census information for each polygon (assuming an even distrubution).
**Jeff's tool is available on ArcScripts. Search on his name.
| NPS Fish Species Application - Sarah Nelson (3 part video) Part 1, Part 2, Part 3 |
More projects...The National Park Service conducted a regional study covering several National Park Service units with similar ecological characteristics. During this study, data was collected on fish species found at various sites across Virginia and Pennsylvania between August 2002 and June 2005. Research data has been compiled into an Access database that contains site id’s corresponding to 2 shape files which represent the physical locations of those sites. This project involves building an interface in ArcMap that will query the database for locations where a particular fish species was found. The resulting sites will be added to the map as a new shape file. The National Park Service plans to use this application as a way for individual parks to show the location of fish of interest. Researchers or park personnel would have a better understanding of where the collection point or transect is located and the surrounding landscape.
Programming Languages:
Python is used as the scripting language because it is a nice 'starter' programming language. It is a highly readable language. It has an uncluttered visual layout, using English keywords frequently where other languages use punctuation. Some languages require a lot of set-up code before the simple procedure of outputting text is performed. With Python this is not so. For example, the code you need to print Hello is print "Hello".
Visual Basic for Applications (VBA) is used because it creates graphical user interfaces with ESRI's Arc products, currently the most popular GIS software. VBA is an implementation of Microsoft's Visual Basic, an event driven programming language, meaning flow of the program is determined by mouse clicks and key presses. The integrated development environment (IDE) where the code is edited, is built into Arc applications (as well as other Microsoft Office software, such as Access and Excel).
Topics:
| Course Schedule |
This material pertains to the fundamental concepts in geospatial programming at the graduate level. There are three main references for the course material: Guido van Rossum's Python Tutorial (PT) Chapters 3-8, "Writing Geoprocessing Scripts with ArcGIS" (WGS) Chapters 1-7, and "Getting to Know ArcObjects Programming ArcGIS with VBA" (PVBA) Chapters 1-14, 17, 18. Here's a topic summary:
| 1. Introduction | (1 week: WGS Ch 1, 2) |
2. Data structures, debugging, geoprocessor object & tools |
(1 week: PT Introduction, WGS Ch 3) |
| 3. Flow control, Describing data | (1 week: PT Flow control, WGS Ch 6) |
| 4. Debugging and batch processing | (1.5 weeks: WGS Ch 2, 4) |
| 5. Messaging, error handling, procedures | (1.5 week: WGS Ch.5, PT Errors, PT Functions) |
| 6. Cursors, dictionaries | (1 week: WGS Ch 6, PT Dictionaries) |
| 7. Reading and writing data tables, GUI's | (1 week: WGS Ch 6) |
| 8. Code reuse: modules, classes | (1 week: PT modules, classes) |
| 9. Introduction to VBA, calling Python | (2 weeks: PVBA Ch 2-9) |
| 10. Using ArcObjects | (2 weeks: PVBA Ch.10-14, 17, 18) |
Learning Outcomes:
Homework assignments and projects will require students to demonstrate the following skills:
Modify existing scripts found online or exported from Modelbuilder or write custom scripts to:
- Preprocess data files
- Perform geoprocessing on distributed files
- Automate repetitive tasks to enhance workflow
Use the scripts:
- Stand alone
- Incorporated into Modelbuilder models
- Called from VBA applications.
Use VBA to:
- Build customized interfaces for Arc user interaction (adding buttons to toolbars, creating dialog boxes, etc.) and performing fundamental actions such as capturing user input and modifying map layers.
- Call python scripts from VBA to perform geoprocessing.
- Use ArcObjects to perform some basic operations such as executing commands, adding layers to a map, controlling features display, and working with selected features.