Module 6: Geometries

The assignment for this week took many of the topics from past modules to create a script using ArcGIS Pro Notebook to perform the following task: 

  • Create a search cursor for the rivers shapefile and creating a TXT file to add the results of the OID, vertex number, coordinates, and name for each point of each river feature. 
A psuedocode of the final script is included below: 

The first thing in the script is to import the env, arcpy, os, and fileinput, and set the workspace to an output folder. Also, the overwrite.output needed to be included so that the script can be run multiple times and overwrite the previous files. Then the search cursor is used to search for the OID (OID@), feature (SHAPE@), and river name (NAME). The results were set at the cursor variable. A for loop is used to define each row in the cursor, with a nested for loop to define the every point of each river feature, as polylines are made of multiple points. To create a sequence of vertices, another variable is created for the vertex numbers and set to +=1. Then the results are printed and written to the txt file using the "\n" to print each vertex attributes on its own line. A screenshot of a portion of the file results are included below: 

The first number is the OID number for the river feature, the second number is the vertex number of the river feature, x coordinate, and y coordinate. Overall, the results included 26 features, with over 200 vertices. After this, the cursor is deleted and the file is closed. 


Comments