Module 1 - Introduction to Python


ESRI has officially embraced Python as the preferred scripting language for ArcGIS products (Zandbergen). And so, I am fully embracing the learning of it as well. In my short 3 years as a GIS professional, I have already (and very quickly) recognized the power of programming. I've been so anxious for this class to start. I love the idea of automation, mass producing, and "working smarter", as the saying goes. Possessing this invaluable skill is not only essential for any technologist wanting to stay relevant, but really, who likes to do menial, repetitive tasks in GIS anyway? Not me!

In our first week of class, we got an excellent introduction to the mighty Python. Created by Guido van Rossum in the Netherlands, and first released in 1991, Python is free and open source software. One of the strengths of Python is that it is both a programming and scripting language. What is the difference? Programming allows you to build components from scratch, while scripting allows you to connect various (of these existing) components to accomplish a new, related task. For this class (GIS5103 - GIS Programming), we will be focusing on learning the scripting fundamentals of Python to extend the capabilities of ArcGIS software. (Zandbergen)

For our lab exercise, we were introduced to IDEs (integrated development environments) or Python editors, specifically IDLE (Python GUI) Python Shell, PythonWin, and the ArcGIS Python Window. IDEs improve the programming experience. For the remainder of this class, we will use PythonWin because of its numerous advantages on the Microsoft Windows platform (Zandbergen). However, other IDEs can be downloaded here: http://wiki.python.org/moin/PythonEditors.


For our lab assignment, we were tasked to run an already-created Python script that automates the creation of folders and sub-folders for the rest of the semester in our student drive. In order to the run the script, we first opened it in PythonWin, and then clicked on the little-guy-running (how I like to call it). The script ran in less than a second; a screenshot of my results are on above. Two important things to remember here: 1. the cursor can be placed anywhere within the script window when wanting to run the script, and 2. remember that running a script automatically overwrites any earlier versions of the script that have the same name.

Additionally, we learned about pseudocodes, flowcharts, syntax, and sequence control structure. And finally, we were enlightened by the philosophical Zen of Python. While reading the Zen of Python, I was immediately evoked by virtues of simplicity, truth, and transparency. This collection of 19 aphorisms act as principles influencing the original design, and the continued improvements to the Python programming language. Its author, Tim Peters, is steadfast, resolute, and firm in keeping this programming language easy to use and easy to understand. There are several instances where he reinforces this idea, check it for yourself by clicking here: https://www.python.org/dev/peps/pep-0020/, or by typing import this in any Python command prompt (>>>)!

References:
Zandbergen, P. A. (2013). Python scripting for ArcGIS. Redlands, CA: ESRI Press.

Comments