Module 6: Working with Geometries
For this weeks lab we were assigned to write a script that creates a TXT file and write to it the coordinates and object IDs for vertices in a shapefile. My script created a new TXT file called rivers_bat33.txt. The script I wrote writes to the txt file, point data for all vertices (0-25 features, total of 247 vertices). Each point has the following information: Feature OID, Vertex ID, X coordinate, Y coordinate, Name of the river feature.
Below are screen shots of the txt file showing all the requirements for the lab showing: Feature OID, Vertex ID, X coordinate, Y coordinate, Name of the river feature.
The flow chart for the script I created is shown below. I don't know if my nested for loop is correct as I didn't know how to correctly show the other outcome.
Notes:
- Points, polylines, and polygons are geometry objects. Working with geometry objects and their properties by setting a cursor on shape field of a feature class. You can work with the full geometry object including all its properties such as length area, but you can also use geometry tokens (SHAPE@XY) as shortcuts to specific properties.
- Reading geometries can be accomplished using search cursor. Specific approaches are necessary to read the properties of multipart features and polygons with holes.
- The spatial reference can be set on cursors to work with geometries in a coordinate system that is different from that of the feature class.