Wednesday, May 25, 2022

Programming in GIS - Python Fundamentals

 

Hard Won Numbers:The final output of this lab may not look like much, but it represents plenty of single-line-print()-checks and “breaks for fresh air”.

    In the first weeks of the GISProgramming course we were asked to get familiar with different systems for writing python code, and to complete a handful of simple tasks using python. These included a code that would print your last name given the full name as a string, edit and run a code that played a simple dice game, and create code to build a list of random numbers and then automatically edit a given “unlucky number” out of the list.

    While we were given the information we needed in the exercises, lectures, and readings, once the different individual tools started to stack and interact with each other, there was still plenty of space for syntax errors and arguments that wouldn’t accomplish their goal. I am happy to say though that for every blank frustrated stare and break for fresh air, there were experiential lessons learned, and new personal checks formed.   

As someone who thought I understood python basics already, I can say it takes more than one infinite loop to realize when your arguments just won’t work.

When Things Get Variable: What happens your loop-breaking argument isn’t a valid argument.

Once the code for each task was built, checked, and running properly, the process looked like this:

   
 I didn't expect to enjoy the flowcharting aspect of this assignment so much, but it did really help me think of my code as one big piece with individual steps, and I realized after making it that in one or two places I was actually calling or importing something that I had already done further up in the code. An easy mistake to make when debugging and problem solving gets you so focused in on checking individual lines, but worth sketching out a chart in advance to catch that sort of thing. 

Lessons Learned:
  • Check your classes
  • len() isn't a good argument to use as a loop breaker 
  • Utilize different consoles to run entire files, run single lines, or edit with more/less prompts and tips
  • Super helpful to print() individual lines or blocks, then just comment it out
  • Check your classes
  • Worthwhile to have a flowchart, even just a quick sketch, when working with a long multi-outcome block of code

GIS Portfolio

 As a final assignment at the end of my time with University of West Florida, I have built a GIS portfolio StoryMap. The final product is em...