Programming Week 6: Geometries

In the last lab of the course, we were given a shapefile of rivers on Maui and had to write a .txt file of these rivers' names, information, and the XY coordinates of their vertices. We did this by creating a search cursor that iterated over each point in each array for each row in the rivers.shp file. Each row in the original file contains the information for a different river represented by a polyline feature. The points in each feature's array are the vertices that determine the curve of the line. For each feature, I numbered the vertices with a vertex ID. The resulting .txt file printed the feature ID, vertex ID, X coordinate, Y coordinate, and the river's name, as seen below. 

The one part of the script I struggled to write was the for loops for the cursor. Specifically, I wasn't sure how to format and concatenate the fields to be written to the .txt file. I tried using the field names themselves with different containers/field delimiters (for example, str("OID@"), {OID@}, str(OID@), etc.) and getting errors about nonexistent columns. After reading the discussion board and reviewing the Module 6 exercise, I realized that I needed to represent the fields with row indexes, like str(row[0]).

Otherwise, I found this lab to be pretty simple, and I'm a little sad that it's the last week of programming class! I hope to keep learning and practicing my Python skills to do even more fun things in ArcGIS Pro.

Comments

Popular posts from this blog

Week 4: Vector Analysis

Remote Sensing Final Project: Change in NDVI Over Time