GIS Programming Module 3: Debug & Error Handling

 In module 3 we covered debugging and error handling. Debugging and error handling are important aspects of writing code in python. Debugging involves identifying and resolving errors in the scripts you write. Error handling focuses on potential issues and managing them during runtime. 

In our lab assignment we got some hands-on experience debugging and error handling three different scripts. For the first, we were given a script with the task to identify and fix two errors. This involved examining the code for logical flaws or syntax mistakes. Once the errors were identified I ran the code to make sure that the errors had been fixed and that there were no more errors. The complexity increased for the next two scripts. 

The objective of the second script was the same, identify the errors or exceptions so that the code could run properly. The second script was more challenging due to a file path error. The file path was inaccurate in the script and needed to be corrected in order for the script to access the proper files and produce the correct results. Once the file path was corrected along with several other errors the script ran properly. 

On the final script we utilized the try-except statement.  This is a fundamental tool for error handling. It allows you to "try" a block of code that may contain or cause errors. You then use an "except" block at the end of the script which prevents your program from crashing and allows you to manage the error properly. Below is a flow chart that will help to visualize the try-except statement.


This module was very insightful, and I look forward to using what I have learned in the future. 

Here are the scripts I ran with my comments. 

Script 1 



Script 2 


Script 3

Comments

Popular posts from this blog

Final Project Bobwhite-Manatee Transmission Line

W01 Overview of ArcGIS - Orientation Lab (1)

Module 4: Data Classification