Wednesday, July 12, 2017

GIS Programming Module 7: Manipulating Spatial Data

This week we tackled some new data structures and the use of cursors to find and edit data in tables. The script for this week's assignment had a number of steps:

create a new geodatabase > create a variable containing a list of all the feature classes in the module data folder > copy each shapefile from the module data folder to the database > create a search cursor that retrieves name, feature, and population for only the county seats from the "cities" shapefile > create an empty dictionary > add the name and population of each city to the dictionary > print the dictionary

It also prints messages at each step to let the user know what's happening and whether the script is running correctly, as you can see below in a screenshot of part of my script's output:


The hardest part for me this week was writing the search cursor correctly and then the right code for adding data to the dictionary. At one point after sorting out the latter, I was still getting mysterious error messages (I was running lines of code in the interactive window as I went so I could see if they worked before writing them into the standalone script) and it turned out I still had a problem with the search cursor. It's always syntax issues for me!

No comments:

Post a Comment