Posts

Showing posts from June, 2024

GIS Programming Week 5

Image
This week I learned about manipulating spatial data within Python. I used what I learned to create a script that creates a new geodatabase, copies shapefile data to that new database, and creates a Search Cursor and dictionary to isolate and print County Seat cities in New Mexico and their respective population circa 2000. I found the first few steps of the lab straightforward, but first ran into trouble when creating the Search Cursor. At first, the output printed on the same line and looked very messy. To fix this, I ended each line by inserting an escape character <\n> to the script, which fixed that issue. I had the most trouble populating the empty dictionary. The output initially only gave me the last key in the dictionary, but I realized this was because the line of code creating the empty dictionary was blocking the for loop, so I moved it up a few lines and was able retrieve the whole dictionary successfully. I also ran into trouble while trying to place all of my print ...

GIS Programming Week 4

Image
     This week I learned how to create a model for geoprocessing function in ArcGIS using ModelBuilder. Creating a model using ModelBuilder within ArcGIS Pro was a great visual tool that helped me understand geoprocessing tools and visualize the workflow. It is very useful when creating tasks that need to be repeated. Below is the model I created to show the process of clipping a feature, and then erasing a selection within the feature, as well as the output. In this case, removing any polygons representing "Not prime farmland" within a map of soil clipped from a basin. After running model Before running model      The next part of my assignment was to write my own script in ArcGIS Notebook that could run add XY coordinates, buffer, and dissolve tools. I exported the model I created to a Python script and inspected it, which further reinforced my understanding of how the geoprocessing tools function. This, along with the readings and practice assignment gav...

GIS Programming Week 3

Image
       This week I learned the basics of fixing errors within your Python script, a process called debugging. I was provided with a few scripts that contained several errors, and it was up to me to address the issues and make the script functional.  To find the problems in the code to debug them, I first ran the script to see what errors occurred. The error messages in the Python Shell were quite helpful as they told me what type of error it was, as well as the specific line it came from. Most of the troubles were simple spelling or syntax errors, which were easy to fix and help further familiarize me with the proper grammar of Python. I found the entire process quite enjoyable and rewarding. Below is the final output of the first two scripts I fixed, which retrieved shapefile information from a project in ArcGIS pro.      For the final script, I was told to not fix any errors found, but to instead employ a "try/except block", a tool used to work ...