Tuesday, June 24, 2025

Module 6: Geometries

 Module 6: Geometries

This weeks lab was about how to use geometries within Python and ArcGIS Pro. We wrote a script that creates a TXT file and write to it the coordinates and object IDs for vertices in a shapefile. This lab had us use two for loop statements. It was more difficult to understand how to make two for loop statements. Working with geometries is very time consuming but we learned about how to use geometry tokens. Geometry tokens provide shortcuts to specific geometry properties of individual features in a feature class. Another important factor we learned was when reading geometry types (polygons and polylines) requires extra code because an array of point objects is returned for each feature. As a result, an extra iteration is required to interact with the array first before you can get to the points that make up the array. This is where the for loop statements came in and made it easier to get all the information we may need. So that we did not have to do another for loop statement we did the getPart() method. The getPart() method returns a single point object for one single-part feature. If it is a polyline or polygon, it returns an array of point objects of the different features you are trying to get. In short, the getPart() method allows you to access and look through the different parts within a single geometry object. The hardest part I had was getting the information to print in the textfile and I remembered using the Try statements so that I could do the except and finally statements so that I could get the information to print. Being able to use those statements were important because it could show me where the issue was happening before things printed into the text file. Lastly, my other issue was figuring out the .write() statement so the information did actually write into the textfile. That is when I created the line I wanted to write and then put it the parentheses. The image below shows a portion of the information into the textfile.

This image below is the flowchart of how I created the script for the information I wanted for the rivers shapefile. Once again it was difficult to show the for loops and how they were being represented.

This module was probably the most difficult one because of the two for loop statements and getting the information to write into the textfile. Once I remembered the try statement I was able to make sure I got all the information correctly into the textfile.

No comments:

Post a Comment

Blog Post #5: GIS Portfolio

 Blog Post #5: GIS Portfolio In the final weeks for the GIS Internship we were given the task of creating a GIS portfolio either on paper or...