>>> print ("Hello Everyone!")
Hello Everyone!
Feature > Array > Vertex
For this weeks lab, I was tasked with working with the aforementioned geometries. I was given a shapefile containing river features from Hawaii and was tasked with writing the geometries of each feature to a newly created TXT file. For my text file, I needed individual lines that provided me with the following information: Feature ID, Vertex ID, X Point, Y Point, and Feature Name. In total there were 25 features in my data and 247 total vertices that I had to list with their respective X and Y points and feature names. Before I get to the results, I would like to share the basis of my code so you can understand how I got my results.
~To Do:
T
1.
Set my environment parameters2. Create a new TXT file that’s writable
3. Create a search cursor that calls on OID (Object ID), SHAPE, and NAME
4. 3 For loops:
a. First: Iterates Rows
b. Second: Iterates Array
c. Third: Iterates Vertices
5. Print and Write my results in the script and new TXT file
a. Feature #, Vertex #, X Point, Y Point, Feature Name
6. Delete row and cursor variables
7. Close file access
Start
>>>import statements
>>>environment statements (workspace and overwrite)
>>>define feature class
>>>open new writable file
>>>define the cursor
>>>for loop to retrieve rows
>>>for loop to retrieve arrays
>>>for loop to retrieve vertices
>>>print and write to the newly created TXT file
>>>delete row and cursor variables
>>>close file
End
>>>import statements
>>>environment statements (workspace and overwrite)
>>>define feature class
>>>open new writable file
>>>define the cursor
>>>for loop to retrieve rows
>>>for loop to retrieve arrays
>>>for loop to retrieve vertices
>>>print and write to the newly created TXT file
>>>delete row and cursor variables
>>>close file
End
My results turned out better than expected (below):
As you can see, new lines were written to my TXT file starting with Feature 0 then iterating through each Vertex in the array providing you with the X point, Y point and the name. Once Feature 0's (Honokahua Stream) vertex array had been iterated through, Feature 1 (Honokowai Stream) was iterated through next until all 247 vertices were complete for the 25 features total. Overall implementing the nested for loops in my script was the toughest part and caused the most hangup for me. The final module will be one of my favorites in this class as it pertains to Raster data!