Module 5 - Exploring & Manipulating Data

     This week's module had us create a script that would be able to create a new geodatabase, copy all feature classes from one database to the other, uses a search cursor to create a list of data, and populates an empty dictionary using another search cursor.


    The first part of the script uses CreateFileGDB_management to create a new geodatabase. CopyFeatures_management is then used to copy the reference feature classes into the newly created geodatabase in the outputEnv file path. Below is a flowchart which summarizes this part of the script.


    The second part of the script uses a SearchCursor to create a list of County Seats within the cities feature class, returning their names, feature types, and populations circa 2000.


    This part of the script uses SQL within the SearchCursor to only search for County Seat feature types within the cities attribute table. Using row.getValue() and defined variables, I was able to print each set of data. Below is a summarized flowchart of this section of the script.


    In the last part of the script, I encountered difficulties while populating the empty county_seats dictionary. My dictionary printed an empty set {} initially. In order to fix this issue, I had to first update my workspace to the output environment. I had also mistakenly assumed that Python would store the previously used cursor, and had to correct this by re-creating the same search cursor for this part of the script. The dictionary then populated as expected.


    I ended up using the <dictionary_variable>[key] = value method to populate the county_seats dictionary. This final part of the script has a similar flowchart as part B.


No comments:

Post a Comment