Another week, another leap in understanding the world of GIS Programming. This week, we were tasked with debugging three different scripts designed to provide information related projects in ArcGIS Pro. The first script (as shown executed below) provided a printout of the fields in the park shapefile attribute table. In terms of programming, this first script just had some mismatching capitalization, font inconsistencies and an incorrect link to the folder with the shapefile. The fixes were rather obvious and easy to correct for without requiring additional assistance from the debugging tool.
I found and corrected the following errors: A case error with the filepath definition. A missing y when referencing the arcpy catalog. An incorrect filepath for output, an incorrect file path for the project location. A missing e in spatialReference. The "for map in maps:" was incorrectly stated. and A misspelling of map within the code. The debugging tool was a great help in processing this information quickly and easily. The resulting code printed as shown below.
The final challenge was to use a try, except statement in order to successfully run a script without actually correcting the errors. I still had to correct the generic filepaths so that I was actually calling on the correct data before running the code, but I corrected no other errors and simply used the following method to successfully run the code. I input "try:" at the top of the code, indented the rest of the code in part A. I then input the following except statement...
except Exception as e:
print(e)
at the bottom of the code and ran the code. This resulted in the printout below.
No comments:
Post a Comment