The assignment for this module started with a script template which was expanded using the skills learned in the exercise portion of the module. Provided shapefiles were stripped of their .shp extensions and added to a new geodatabase by a scripted for loop. A search cursor was used to retrieve only those cities identified as county seats in the "FEATURE" field of the cities layer . Another for loop was used to populate a newly created dictionary with the names and populations of those county seats. The results of the script are shown in this series of screenshots.
|
Middle Portion of Results |
A troublesome spot I encountered was being unable to delete my geodatabase after having run the script multiple times. That “Failed to delete…” error message became a bit annoying. Initially I started deleting feature classes individually, and then discovered that I could not delete the “cities” layer because of a schema lock. After reviewing schema locks in the text, it became clear that del row and del cursor needed to be included.
The next part of this problem came up: how to run the script with the changes if the geodatabase could not be deleted until the lock was lifted which could not be done without creating a geodatabase. Vicious cycle, I say. A temporary geodatabase was created, del row and del cursor were added to the script, the original geodatabase was unlocked, and deleted. The temporary geodatabase was also deleted, and the script was revised back to the name of the original geodatabase. All of this would have been unnecessary had I remembered to close ArcMap before running Python script. C'est la vie! I'll remember that now!
|
Final Portion of Results |
No comments:
Post a Comment