Labels

Tuesday, May 31, 2022

GIS5103 Debugging and Error Handling

 This week we covered debugging Python script using Spyder . We opened three different pre-written Python codes containing errors in Spyder. We analyzed each one using the step in Debugging tool in Spyder. Once we found the lines containing the errors we were talked with correcting them. 

Our first script contained some fairly simple errors. The goal was for the script to print out all of the fields on our Module2 attribute table. Results are pictured below:


Our second script contained additional errors more complex in nature than those in the first script. The goal here was for the script to print out the names of all the layers in our project. Results are pictured below:

For the third and final script for this weeks lab we were tasked with creating code that would allow our script to run with errors. Results are pictured below:


The main take away I had from this course is that if you write Python code you will have errors. The key is finding a good IDE like Spyder and refining your skills on debugging. It also helped to know that it is possible to make code run even with errors by catching the error and handling it.







Monday, May 23, 2022

GIS 5103 GIS Programming

 Mod 1 Python Fundamentals Lab "Dice Game"

This week we were introduced to the basic fundamentals of Python focusing on its use in GIS. We learned how to access the Python Window in ArcGIS Pro and how to access the Python Command Prompt to utilize Spyder for our programming. We used Spyder for all of our Python script writing int this assignment.

For this lab we first made a script that would print our last name from a list. Next, we were asked to find the errors in a pre-written section of code  for a dice game and correct them. Our next objective was to create a loop that adds 20 random number between zero and ten to a list. For our last step we were tasked with creating a loop that removes a chosen integer from the previously generated list.

It all sounds so simple right? It was definitely a challenge and gave me a greater appreciation for the programming that goes on behind many of the preloaded scripts in ArcGIS Pro.

After making what seemed like hundreds of errors I was finally able to get these results:

As you can see it printed my last name. It also shows what each plyer rolled and if it was a win, loss or tie. The created list of 20 random numbers between 1 and 10 was also printed and lastly we have out list of numbers with the unlucky number 8 removed.

Flowcharting is also used in Python to basically map your script out.  I made one for each of the steps in this lab on PowerPoint.






  

From Fragmented Data to Actionable Intelligence: A GIS Case Study

  Case Study: Building a Centralized GIS Platform for the Cleveland Museum of Natural History Natural Areas Client: Cleveland Museum of Na...