GIS 5103 - Module 3
Debugging: In this module, three scripts are provided with pre-existing errors. I corrected the errors using Spyder's debugging tools, correcting syntax, and using try-except statements.
Issues and Notes:
In this modules, I encountered some errors I had to research a bit to learn how to deal with them and what they mean, I encountered some formatting issues that had to be dealt with before corrected code would work, and I had to use logical thinking to understand first what the process was attempting to do, how it was doing it, and where adjustments or additions were needed to make the code work.
Part 1: Correcting errors
In this part, the code is intended to print the field names in a shapefile. The code contains multiple syntax errors. I was able to identify the errors and correct them.
The steps are as follows:
1) Look at code, lines with errors will be indicated on the right with note on what the error is.
2) I could catch these errors just by looking at it. They included incorrect field names, such as capitalization and extra or missing letters.
3) I ran the code just to insure there was nothing I was missing. The code ran correctly.
Please see flowchart and output of successfully run code below:
Part 1 flowchart: Correcting errors |
Part 1 output: Correcting errors |
Part 2: Debug tool in Spyder
In this part, the code is attempting to find and print the spatial reference of a map, and the layers contained in it. It it encountering 8 errors that must be identified and corrected.
The steps are as follows:
1) I corrected visible errors
2)I ran the script through the Spyder debugging tool to identify which lines were encountering errors.
3) I modified the script to account for those errors, as I saw them. Some error types I had to research how to adjust them.
4) Run modified script.
Please see flowchart and output of successfully run code below:
Part 2 flowchart: Debugging tool in Spyder |
Part 2 output: Debugging tool in Spyder |
Part 3 output: By-passing errors using try-except statement |
Comments
Post a Comment