In this weeks lab, we learned about ways to explore and manipulate data in feature classes. We started by creating a new file geodatabsae (fGDB) and then we copied feature classes into the fGDB. Then we used a search cursor to identify the records in an attribute table that met certain criteria. Tis was similar to the function of a select by attribute in ArcGIS Pro. Last we used the search cursor to then populate a newly created dictionary that was used to index the records that matched the criteria from the search cursor.I have attached a flow chart of the steps taken in this weeks lab as well as a more in-depth discussion of the steps and the issues encountered during each step.
1. Creating the file geodatabase/copying the features: This step was straight forward. I was able to modify the script that I used in the exercise for module 5. I had to update the directories and I changed the name of the file geodatabase to jreimer. Then, I assigned the feature classes in the working directory to a list and then copied the features into the newly created jreimer file geodatabase. Last, I added the print statements, and I checked to make sure that the script was properly running using the statements. See script results below.
2. Search cursor: This was the step that I had the most issues with. Thanks to print statements I was able to deduce that the search cursor was running properly but it was not identifying the rows of interest (or any rows for that matter), so no output was being printed. I was able to review the attribute table of the feature in ArcGIS Pro which allowed me to identify the typo in the directions. I was able to update “County Seats” to “County Seat” which resolved that issue. I soon realized that my print statements were giving me errors for this step. After, I briefly research the error code, I realized that it was an error that I had encountered in a previous assignment. I was calling the output from row.getValue() function within a print statement which was giving me output that was not in a string format. To resolve the issue, I used the str() function to convert the output into a string format so that it would properly print the statement. See script results below.
3. Dictionary: I had few issues with this step. I started by creating the empty county_seats dictionary and used the same search cursor from the previous step to identify the rows in the attribute table that were of interest. Then, I used a for loop and the templates for adding items to a dictionary that were outlined in the assignment sheet to populate the county_seats dictionary with the selected values from the search cursor. Last, I deleted the row and cursor, and I printed the dictionary. See script results below.
This concludes this weeks lab. Stay tuned for next weeks assignment on working with geometries with python!








No comments:
Post a Comment