Programming Module 5

 

 Module 5


The first section of the Python script I was relatively successful creating a new file GDB in the results folder of module 5 and copying the shapefiles into it. I spend too much time explaining as my code below is relatively simple:


Creating a value that lists all  feature classes was relatively simple as it only consisted of two lines of code. 

arcpy functions are crazy powerful in an environment that has access to the esir .bat and .lib files. they make it very simple and quick to create desired outputs. 

In this module I ran into a few issues with setting up the correct parameters for running the search cursor and expressing a for loop that incorporated a delimited function. 

Iterating through shapefile attribute tables can be sort of tricky depending on what you are wanting to do. 

In this module we wanted to look at two fields which were City and Population in a specific shapefile within our file geodatabase which is different than a regular GDB. 

Cities were classified as "NAME" field and population was classified as "POP_2000"

A third field was also thrown in the loop which was labeled "FEATURE".

In this column labeled "FEATURE" there were certain rows that contained the text "County Seat" 

These rows were what I was looking for when iterating through the shapefile along with the cities associated with county seats and their population. 

Below is an example code I wrote:


I first defined the shape file :

fc = "cities"

then defined the fields in the shape file, after which I defined my arcpy.AddFieldDelimiters( ). 

Once this was done I defined the where_Clause and started my with as loop followed by a for in loop. 

along this code I added some print statements to let me know where the code was at. 

Lastly is an image of my full script for module 5 lab assignment. 















Comments

Popular Posts