Posts

Showing posts from June, 2021

Working with rasters

Image
 This week was learned how to work with rasters in Python. Our assignment was to write a script that created a raster that identifies areas where the landcover, slope, and aspect meet specific parameters. I began writing this script by importing the arcpy spatial analyst module and all of the functions. Next,  I began an if statement that contained the majority of my script. It begins with a conditional statement and notifies the user if the spatial analyst module is available. If it is not, then the else statement tells the user that the license is not available.  The if statement checks the spatial analyst module out and in. Next, it reclassifies the land cover. Then, it calculates the desired slope and aspect. It then combined all of these rasters into one final raster and saves it as a tif file.  The final output is included below.

GIS Programming- Working with geometery

Image
 This week we learned how to work with geometries. Our assignment asked us to create a new .txt file and populate it with data from a shapefile. We were to include the object ID, the X and Y coordinates, and its name. I used a search cursor and nested for loop to accomplish this task. The trickiest part was making the .getPart() function to work. I kept receiving errors stating it could not be retrieved. I was able to solve this issue by moving the fields around in the search cursor's tuple.   I have included the script's output and flowchart below.

GIS Programming- Exploring and Manipulating Data

Image
 This week we learned about exploring and manipulating data in ArcGIS Pro with Python scripting. We learned about a variety of tools and methods, such as describe, exist, listing, dictionaries, and cursors. In the assignment, we were given a variety of tasks. First, we were to create a new file geodatabase. Next, we were to list all of the feature classes in another folder. We then copied those feature classes into the new file geodatabase. Using one of the files in the new geodatabase, we used the search cursor to identify the objects that matched specific criteria and printed that information. Finally, we created a dictionary with this information.  I encountered issues with populating the empty dictionary. I was attempting to use the row.getvalue method,  I kept receiving the error that my tuple did contain the attribute. I began my troubleshooting by searching for various methods to update dictionaries. From there I edited small things in my script, such as the input ...

GIS Programming- Geoprocessing

Image
 This week we learned how to complete geoprocessing tasks with python scripts and models. The goal was to create a model in ArcGIS Pro and a python script. The script was to create XY coordinates in a shapefile, then create a 1000 meter buffer around it, and finally dissolve the buffer into a shapefile. I began this script by establishing my module and environments. I imported the arcpy module and my environment. I based this on previous template scripts. I then established my workspace and shapefile. Next, I created the XY coordinate script. I added the AddXY function and instructed it to print a message when done.  To create the buffer, I used the buffer analysis function and established my parameters. I set my buffer to 500 meters so the diameter would be 1000 meters.  To create the dissolve buffer script, I used the dissolve function with my input and output.  Finally, I inserted two print messages after each function. The first message informs the user what...