Posts

Showing posts with the label Python

GIS 5103 Module 6 - Working with Geometeries

Image
For module 6, we learned how to work with search cursors to pull geometric information from a shapefile. This required the creation of nested for loops, however this wasn't without issues due to the instruction to close the file and cursor. This required moving on from for loops to using a try/ finally construction rather than the code as demonstrated in the textbook which used a with along with the nested for loops, the with architecture automatically closes the cursor & file when all the for loop criteria have been met.   Overall, this week's exercise seemed easier than that of the previous week, perhaps because I was already familiar with the tuple call which gave me some difficulty in module 5.

GIS 5103 Module 5 - Explore & Manipulate Data

Image
For this week we had to work with creating a new fGDB and then listing the feature classes to be copied to the new geodatabase using Python, each shapefile is then copied to the geodatabase  After iterating through each geodatabase a search cursor is initiated in order to produce the county seats within the cities shapefile along with their population Finally, a new dictionary called county seats is created and each of the county seats and their population is fed into the new dictionary and the new dictionary is printed

GIS 5103 Module 4 - Model Builder

Image
  For week 4, we moved from learning the basics of how Python functions to using it within the ArcPro ecosystem. We learned how to use modelbuilder and how to write code necessary to complete basic geoprocessing steps like buffers and clips.  For our results we included printed comments in order for it to be possible to see what code was executing when. 1         To create the xy coordinates, I pulled from the demo code on the Add XY coordinates help page, changing variables as necessary, and adding the print GetMessages function 2         To create the buffer, I first tried using the demo code available from ESRI help, but ran into it trying to do more steps than I wanted, so I built what I wanted in model builder and sent it to the python window and used that to create the code I needed, modifying names & code as necessary 3         I returned to my model builder to h...

GIS 5103 Lab 3 - DeBugging

Image
  For this week's lab we were asked to de-bug 3 separate instances of python scripts. For the first script we were asked to work through the code to debug it, the majority of the errors within this code chunk were simple punctuation and capitalization errors The second script was much the same, though errors were more complicated and included issues like an incorrect file path. For the third script, we were asked not to fix the code, but in fact to insert a Try-Except process to allow the code to run without fixing the error. For me, this entailed inserting the try function above code line 13 and then catching the exception after approximately 8 lines My full process for working through the creation of the Try-Except loop can be seen below Python 3.11.10 (main, Sep 20 2024, 18:44:55) [MSC v.1938 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. ========= RESTART: S:/GISProgramming/Module3/Result...