Wednesday, June 17, 2026

Module 6 Blog: Working with Geometries and Search Cursors

 For Module 6, I created a Python script that uses geometry objects to extract vertex information from the rivers shapefile. The script uses a SearchCursor to access each river feature’s object ID, geometry, and name. From there, I used the getPart() method to access the vertices that make up each river line.


[Insert screenshot of completed rivers_.txt file here]

The screenshot above shows part of the TXT file created by my script. Each line includes the feature OID, vertex ID, X coordinate, Y coordinate, and river name. This confirmed that the script successfully wrote vertex information for the river features.


[Insert flowchart image or exported draw.io flowchart here]

The flowchart shows the basic logic of my script. The process begins by importing modules, setting the workspace, creating the SearchCursor, and opening the output TXT file. The script then loops through each river feature and each vertex within that feature. For every vertex, it writes the required information to the TXT file and prints the same information to show progress.

One important part of this assignment was understanding why SHAPE@ was needed instead of SHAPE@XY. SHAPE@ gives access to the full geometry object, while SHAPE@XY would only return one coordinate pair. Since the goal was to write all vertices, the full geometry object was necessary. Overall, this lab helped reinforce how nested loops are used to work through features, geometry arrays, and individual points.

No comments:

Post a Comment

Module 3 - Coastal Flooding

 Coastal flooding is one of the most destructive hazards associated with hurricanes, making accurate flood modeling an important component o...