GIS5103 Module 5: Exploring & Manipulating Data

As someone who can be too curious for her own good, I found Module 5 enlightening for my adventurous side, as it covered data exploration and manipulation. We tackled a lot of data description and listing, lists and dictionaries, as well as Search, Update, and Insert Cursors. This module took us to Alaska and New Mexico using shapefiles. Definitely the most intriguing part of this lab for me was manipulating spatial data. As much of the work we do at my job involves updating attributes, I am already itching to automate similar tasks in my workflows, which would save me a lot of headaches and time and reduce human error.

This week's script was another free-rein script, where we got to build it from scratch. Although the lab instructions did request us to use certain GetMessage() functions, line structures, and the sort, which was not a huge issue. It reminds me of the many ways you could go about it. Before I even looked at the lab instructions, I tried to build the script based on the framework and our experience in the exercise, both of which are good references to use as a starting point.

The script called for a 3-step process:
  1. Create a new GDB for feature classes.
  2. Copy the designated shapefiles from the Data folder to the new GDB.
  3. Create a Search Cursor to isolate cities that are County Seats (from Feature Type) to then populate a dictionary with name and population numbers for each.
The first half of the script was the easiest part. The most challenging turned out to be the Search Cursor portion. Largely because I misunderstood the comment lines and thought of not moving the country seat dictionary to a different placement. Since I had it after my Search Cursor, it wasn't populating correctly. At one point, I was pulling only the last record; at another, it was a new city record on each line, not like a dictionary block.

I also made another slight hiccup with the count line for the GetMessage() function at the beginning. I thought I was being smart by defining the count variable early, but it threw off each geoprocessing tool's result messages, causing both the "Start" and "Succeeded" lines to print, despite the lab instructions requesting us to omit the "Start" line by having the (count - 1) argument.

They were both easy fixes, thankfully, and I was able to produce the required output successfully, as shown below.

Module 5 Script Results - Step 1 & 2: Create new file geodatabase and copy over shapefile features into said GDB.



Module 5 Script - Step 3: Iterate using Search Cursor to curate all city records that are a "County Seat" and their population. Then, creating a dictionary based on these County Seat cities.

Module 5 Script Flowchart. Script has 3 main blocks. If needed, each of those blocks could be broken down further, with each of the main blocks being its own flowchart and more intricate as well as clear that there are loops and print statements within each of those 3 main block functions. I chose to leave them together for the sake of time and simplicity.

Comments

Popular posts from this blog

GIS5050 Final Project: The Bobwhite-Manatee Transmission Line

GIS5007 Module 2: Typography

GIS5007 Module 3: Cartographic Design