Module Six Working with Geometries
Here we are in our final week of GIS programming working with Geometries in module 6. Some of the topics covered this week nested/search/for loops and writing to a TXT file. Some of the learning outcomes from this week's lab included being able to create a search cursor to iterate over shapefile geometries and the ability to write vertices of a geometry to a text file.
Here below I have shared a flowchart I created that shows the workflow process of the script. For this script we were tasked with writing TXT file for all vertices in a shapefile. This script loops through every river feature in a shapefile, looking into its geometry and writing out every vertex's location and identification.
Below is the output of the text file after running the script. the full output is 25 features and a total of 247 vertices. Each point list the Feature OID, Vertex ID, X & Y coordinate and the Name of the river feature. I used IDLE for creating this script and like in previous labs I took the same approach working through the script little by little. This is a huge help to figure out what might have gone wrong. The error messages are a lot more straight forward. It also helps to keep me from getting overwhelmed. For the most part this script went smoothly following the provided steps and provided reading material. I
had no problem creating the TXT file, however I struggled with getting the file
to write. I ended up opening the created file and keeping it open and then it
worked fine. Also, I knew I needed to have the “\n” at the end of my file.write line of code for the data to go onto a new line, but it took me a bit to figure out how to
add a space in between the lines, which was solved by adding an additional “\n\n”.
Comments
Post a Comment