Friday, July 10, 2015

Explore/Manipulate Spatial Data

This has been a difficult week. As we approach the Final for GIS Programming, I am having feelings of apprehension regarding my Python coding skills. This week we worked on writing a script that would create a new geodatabase, copy data from one folder into the new geodatabase and populate a dictionary.

The reading included Chapter 6, "Exploring Spatial Data" and Chapter 7, "Manipulating Spatial Data" from our text book, by Paul A. Zandbergen.  This was all good information and appropriate sample code. Yet, I still had hurdles I could not surmount.

Creating a new geodatabase wasn't that bad:

>>>arcpy.CreateFileGDB_management("S:/GISProgramming/Module7/Results", "gcastillo.gdb") # Creates new gdb.

Copying data from one folder into the new geodatabase wasn't even that bad:

>>>arcpy.CopyFeatures_management(fc, "S:/GISProgramming/Module7/Results/gcastillo.gdb/" + fcdesc.basename)


But, I have not been able to populate the dictionary properly and then get it to print out. The "Good People" from GIS5103, Discussion Borad Module 7, even posted the following:
                           
---To populate dictionary---
county_seats.update({row[0]: row[2])
name = row[0]
population = row[2]
county_seats.update({name: population})
    print county_seats

Yet, as many times as I ran my script, this is all I could muster:


I am posting this now because I really do not like to wait til the last possible minute, and in fact, I did not procrastinate on this assignment. I just could not get the correct result. Here's to better luck next time...cheers...

No comments:

Post a Comment