Wednesday, June 18, 2025

Module 5- Exploring and Manipulating Data



Figures 1-4: Creating a File geodatabase and copying data into it.








Flow chart denoting the cradle to grave process of creating a file geodatabase, copying data, and using cursors to retrieve and populate a data dictionary.


This week, we dove into manipulating data using Python. We learned the ease of copying data to geodatabases, creating a search cursor to extract data from said geodatabase, and then creating and populating an empty dictionary.

 

Steps 1-4

 

The first four steps for creating this script were straightforward and had no issues copying the data into the geodatabase. The issue I ran into was when I went back in to add print statements in the for loop for each feature class, I accidentally had all the print statements say “create feature class” instead of listing the desired fields. It was not an easy fix. I had to restart Arc GIS and hope for the best.

 

For Step 3: When using the search cursor, the delimiter function needed to be used. This is what caused the most confusion because I thought I could just use cursor = arcpy.SearchCursor(fc) the and get the results back. But then I realized I had to use the delimitedField = arcpy.AddFieldDelimiters() and this narrowed down the search to the FEATURE class.

Finally, I had to ensure to turn the population field, which was an integer, to a string in the get value field because Python cannot concatenate integers, only strings.

 Step 5

Creating the dictionary deemed to be the most difficult task of all. I could not figure out why the for loop and the chosen function to add pairs of items to a dictionary was printing out an empty dictionary. Finally, after meeting at office hours, I realized that I had to create a second search cursor for the dictionary creation and add the population plus the city names as parameters. Additionally, although dictionaries cannot be indexed, you do need to start as row [0] to start populating values in. This was a key part of the dictionary’s creation.

 


No comments:

Post a Comment

Module 5- Exploring and Manipulating Data

Figures 1-4: Creating a File geodatabase and copying data into it. Flow chart denoting the cradle to grave process of creating a file geodat...