Module 6: Working with Geometries

The purpose of this week's lab was to explore the geometries of a shapefile by writing vertices to a text file. The final script created a new TXT file, used a search cursor to iterate over the rivers shapefile geometries with for loops, and then writing data to the new TXT file. The final TXT file contains the following data from the rivers.shp: feature OID, vertex ID (created in the script), x & y coordinates, and the name of the feature. Below is a screen shot of part of the data in the new TXT file (the full TXT file is not shown as it is very long and contains 0-25 features with a total of 247 vertices).


One of the things that made creating and running this script easy was the use of geometry tokens, specifically OID@ and SHAPE@. Geometry tokens are pieces of code that allow us to interact and access specific information about the geometry of features, which saves time when working with large datasets and/or features with a lot of geometry information.

The only big issue I had  was creating the new TXT file. Simply using the new file name did not create and write to a new TXT file. Instead, I had to include the full file folder path with the name when creating the file. This worked to my advantage as I wanted to save the new file in my Results folder and not the working environment folder, which was the Data folder. Other than the TXT file creation, the main issues were syntax issues which is the same as with every script and new this week was where to use (), [], and {}.

Comments

Popular posts from this blog

Module 6: Proportional Symbol and Bivariate Choropleth Mapping

Module 2: Coordinate Systems

Module 4: Color Concepts & Choropleth Mapping