Wednesday, July 13, 2016

Programming: Module 8

Module 8 lab covered working with geometry objects and multipart features.  The script I wrote creates a text file and writes coordinates along with Object IDs for the vertices in the rivers shapefile.  To do this, I had to import the environment and shapefile.  I used a Search Cursor to get the OID, Shape geometry object, and the Name field.

I had to use the Open function to create the text file and name it as rivers_Mfelde.  In order to get the coordinates, Name, and Object IDs to the text file, I had to create a for loop to iterate over all the rows.  Next, I needed to do another for loop to iterate each point in the array.  I use the .getPart() method to access the points in the array.  I had to add 1 to the vertex ID to help keep track of the vertices.

To get the data in the text file, I had to use the .write() method.  I used the iterate of the first for loop, the vertex ID, X coordinate, Y coordinate, and then the name of the river.  To ensure that I captured everything correctly, I printed the results as well in the interactive window.  I closed the text file.

Below is the screenshot of my text file along with a flow chart that shows the process of creating the script.
Text File Results
Script Flow Chart

No comments:

Post a Comment