GIS4102 - Module 6 - Working with Geometries
points/vertices in each array. Below is a pseudocode of the process in a more specific way.
Start
# Step 1: Setup
Import necessary modules
Enable overwrite output setting
Set the workspace to the Module6 Data folder
Define the feature class variable for rivers.shp
# Step 2: Prepare to write .txt file
Open rivers_dji4.txt file for writing
Create a search cursor for rivers.shp with fields OID, SHAPE, and NAME
# Step 3: Write to .txt file using for loops
For each row in the cursor:
Set vertex_id to 0
For each part in the row's geometry:
For each point in the part:
Increment vertex_id by 1
Write OID, vertex_id, X coordinate, Y coordinate, and Name to the text file
Print the same information for debugging
# Step 4: Close the .txt file
Close the text file
Delete the cursor
End
With the code completed and correctly running, a resulting piece of the code is shown below, showing all 25 features.

Comments
Post a Comment