Module 5: Exploring & Manipulating Data

The purpose of this lab was to explore spatial data with scripting using search cursors, lists and dictionaries. A template script was provided and modified in the Spyder IDE to perform the required functions. The final script creates a new geodatabase called ath22, copies 8 feature classes into the geodatabase, queries the feature class cities for the names and population sizes within the county seat and creates and populates a dictionary called county_seats with names and population size circa 2000 of every 'County Seat' city in New Mexico. Included in the script output are processing messages indicating which process is running, that the process was completed and how long it took to complete the process.

The first tasks of the script created a new file geodatabase called ath22 and copy 8 feature classes into the geodatabase. The code for this part of the script was easy to create. To print the messages with spaces so they are easier to read, it is useful to add '\n' to the end of the print message. Below is the output from the script showing that the geodatabase was created and the feature classes were copied into it.


The next task queried the  feature class cities for the names and population sizes within the county seat. This was accomplished using a Search Cursor. The most difficult part of this code was creating a SQL query WHERE clause that did not produce a syntax error. Because the city name is a string, the use of quotation marks would produce a syntax error. The error was resolved by using backslashes in the place of some of the quotation marks. Below is the output from the script showing that the query was started and completed successfully, printing the required results.

The final task created and populated a dictionary called county_seats with names and population sizes circa 2000 of every 'County Seat' city in New Mexico. The dictionary was populated using the format  <dictionary variable>[<key>] = <value>  where the key was the city name or "NAME" and the value was the population size or "POP_2000". It was helpful to redefine the variable before this portion of code was written. Below is the output from the script showing the the dictionary was successfully created, populated and then printed.



Comments

Popular posts from this blog

Module 6: Proportional Symbol and Bivariate Choropleth Mapping

Module 2: Coordinate Systems

Module 4: Color Concepts & Choropleth Mapping