GIS Programming Module 2
Module 2's objective was to introduce and practice debugging. The assignment for this module including going through and debugging 3 different scripts.
Script 1
The first script that we had to debug was a simple script that prints out the fields of a provided shapefile. The debugging process or this script was fairly simple as can be seen in the flow chart below.
The script simple needed a correction to the file path where it would draw data from and some errors related to either capitalization or missing letters. Below is a screenshot of the results from script after it was debugged.
Script 2
The second script was intended to print out the files in a project. The second script contained various syntax errors and exceptions. The following flowchart shows the steps that I took to debug and run the script successfully.
This script again contained a file path error along with missing characters and spelling errors. One missing character in the script created an exception by not being able to draw the necessary data from a loaded module.
Script 3
The third and final script we worked on was intended to test our ability to find an error and add a Try and Except statement. The Try and Except statement allows the script to run while jumping over an area where their is an error present. This allows for isolation of an error. In this more complex script I used a debugger and ran the script line by line to ensure I caught all errors.
In this last script we were not supposed to fix the error instead we had to use the Try and Except statement to isolate the error and ensure that the second part of the script ran as intended.
Module 2 was very helpful as it made me look closer at scripts and get a better understanding as to how they work. Error messages in Spyder and IPython are helpful to quickly find some errors but more time and effort go into finding hidden errors that lead to exceptions. Some fairly small careless mistakes in code could be really problematic so it is really important to look over all your work.