GIS Programming Week 5

This week I learned about manipulating spatial data within Python. I used what I learned to create a script that creates a new geodatabase, copies shapefile data to that new database, and creates a Search Cursor and dictionary to isolate and print County Seat cities in New Mexico and their respective population circa 2000. I found the first few steps of the lab straightforward, but first ran into trouble when creating the Search Cursor. At first, the output printed on the same line and looked very messy. To fix this, I ended each line by inserting an escape character <\n> to the script, which fixed that issue. I had the most trouble populating the empty dictionary. The output initially only gave me the last key in the dictionary, but I realized this was because the line of code creating the empty dictionary was blocking the for loop, so I moved it up a few lines and was able retrieve the whole dictionary successfully. I also ran into trouble while trying to place all of my print statements. The assignment called for each step to be communicated through print statements, which can help communicate what exactly the script is doing. Unfortunately, I was not able to put any print statements in the section containing the for loop populating the dictionary without breaking the code. The print statement would have blocked the loop, and I was unable to find a fix to this issue, so I chose to leave out the print statement in that section to ensure the script ran successfully. Below is the output of the script.

Creating a new database


Copying data the the new database


List of cities and population from Search Cursor



List of cities and population from Python dictionary












Comments

Popular posts from this blog

GIS Programming Week 3

Cartography Week 5: Choropleth and Proportional Symbol Mapping