Thursday, July 9, 2015

GISProgramming: Module 7 - Exploring and Manipulating Spatial Data

     This module introduced exploring and manipulating spatial data with cursors. This week I worked specifically with the Search Cursor to find certain features in a feature class and fill a dictionary with those selections. Cursors are part of the Data Access Module within ArcPy. Also introduce this week was the Describe function.  The combined use of these tools and functions helped accomplish the aim of this week's assignment. 
     My goal was to produce a program that carried out several tasks -- creating a new geodatabase, moving files into that geodatabase, using a Search Cursor to select specific features in a feature class, and then populate a dictionary with those selections. It did not take long to write this program but I was held up by the Search Cursor. Optionally, the Search Cursor can include a where clause for an SQL query. The particular query I wrote used a combination of single and double quotations. That is an issue for Python, as it will try to interpret these quotation marks as strings and confuse where the string begins and ends. Escape clauses are the solution but I had difficulty employing them successfully. I kept receiving syntax errors for this line of code. My solution was to write a variable for the where clause/query an avoid the escape clauses altogether. This worked well and the program could finally run to completion.  
     I have included a screenshot of the interactive window for this program. I wrote in print statements before and after each task I needed to perform to help keep track of the progress of the program. I found this one of the more difficult programs to write. I usually arrived at a solution quicker for other programs but once I spent some time looking through forums and various ArcGIS Help pages I was able to get work arounds for errors I was encountering. Again, the satisfaction in solving my issues and getting my program to run was great. I hope that I am able to keep this up as the programs and concepts become more difficult. 


An interactive window screenshot of a program that uses print features to track several tasks including creating a new geodatabse, using a Search Cursor to gather specific data, and population a dictionary with that data. 

No comments:

Post a Comment