GIS5103 Module 1: Python Environments & Flowcharts
With summer on the horizon, so is the next semester of classes. I'm coming back to my next GIS course on GIS Programming. I will admit programming has always seemed daunting to me, despite my colleagues reassuring me that Python is one that I can easily pick up. As one with a beginner's level in Python, I hope to prove them right by the end of this course!
For Module 1, we focused on Python Environments and Flowcharts. The textbook and lecture introduced what Python is, various Python editors, and flowcharting. I, for one, didn't know that Python was named after the comedy group Monty Python, not after the snake, which is funny. A cool factoid indeed! As for Python, it's known to be simple, easy, and free/open-source, which gives users greater accessibility than other programming languages.
I thought it was an awesome and effective way for us to see a Python script and how to run it using the CreateModFolder script. Also, it ensures that the students' folder organization is standardized. (Note to others: the CreateModFolder script was originally meant to be run for the S: Drive or the GIS Online Virtual Desktop in mind. So, if choosing to use scripts locally, be sure to check the script for lines of code pathways and adjust accordingly.) I changed line 25 of the script to route all new folders to my C: Drive, so I can work locally, and it worked! It's a minor change, but it felt nice to be able to archive my work on my personal computer.
Throughout the lab, we had to switch between IDLE and ArcGIS Notebook to compare and contrast. IDLE is the default editor provided with Python, while Notebook is available through ArcGIS Pro. Notebook is designed for geospatial analysis, while IDLE provides a basic scripting environment. Depending on your goals, either medium can work, and the Python scripts can be adapted from one to the other if needed. IDLE can seem intimidating because it focuses on just text in a blank window. On the other hand, Notebook offers an interactive, intuitive interface with buttons that let the user navigate or edit the script.
From there, we were tasked to create a flowchart of radians to degrees conversion. I used the app.diagrams.net site in order to create my flowchart, as shown below.
The lab provided the following to base our flowchart on:
| Module 1 Lab - Radians to Degrees Flowchart |
The lab provided the following to base our flowchart on:
- radians = 3
- degrees = radians * 180/pi
With that information and the supplementary document from Agarwal and Goadrich in hand, I created a simple flowchart using various shapes, arrows, and text. I learned there is such a thing as a universal standard in script flowcharts with how the various shapes are determined. This can be found in the Chapter 3 provided documentation from Agarwal and Goadrich.
When testing this in IDLE, my script ran successfully and gave me the proper output of 171.887 for degrees.
When testing this in IDLE, my script ran successfully and gave me the proper output of 171.887 for degrees.
| IDLE Shell window showing the results of my radians to degrees conversion script. |
Finally, we ended on reading and summarizing The Zen of Python, which is essentially a short piece on the importance of succinct and clear scripting.
Overall, a nice introduction to GIS Programming with Python!
Comments
Post a Comment