Geoprocessing - Module 4

 This week's lab was an introduction to geoprocessing tools and their code framework within ArcGis Pro. For this exercise we worked with ModelBuilder and running geoprocessing tools with Python code in an ArcGis Notebook.

The first task required me to create a model to discern the acreage of prime farmland within a specified basin. I was given layers for soil type, which contained a field for quality of farming soil, and the basin which was the geographic region we were studying. Since our soil layer covered a large area, we had to clip the region of just the basin from it. For this, we would use the geoprocessing tool: clip. This would then clip the area of the basin from the large soil type map. 

Within the toolbox of our ArcGis application, we have the option to create a model, which is a visual layout of our processes using the visual representation of various shapes and colors. Different shapes connotate different tools and data types and their color indicates their status within the operation. 

I dragged the clip tool into the model and subsequently added the two shapefiles. By clicking on the polygon for the function, I could then add the input, the area to clip, and the output. This created a flow chart, linking with arrows the data to the function polygon. Arrows can also be added manually without having to open the tool making the GUI of the ModelBuilder definitely simplify the visual utilization of tools. 

I then needed to separate the non-prime farmland from the other qualities of farmable soil within the newly clipped shapefile. I added the tool Separate (separation analysis) to the model and set the input and field I wanted separate from it. I had to use the code FRMLNDQT = 'not prime farmland' to do this. This selected the polygons that delineated the different farmable soil types and separated the not prime farmland from them. 

I then was requested to delete them from the shapefile. Now that they were selected, I dragged the Erase tool into the model and set the newly clipped basin as the shapefile to erase from and the 'not prime farmland' polygons which were selected as the feature to be deleted. 

This was the end result:


The next section of the lab was to add a provided layer which shows the location of hospitals in the greater Austin, Texas region. Using Python code within an ArcGis Notebook (where code can be written and applied in the ArcGis program) we were to add XY coordinates to the attribute table of the hospital locations, add a 1000 meter buffer to each, and then dissolve and boundaries where buffer zones overlap.
I added the hospitals.shp shapefile to the contents tab. The first thing that needed to be done within our code was to import arcpy and set up my work environment.  Now, it is not necessary to add arcpy (the database of geoprocessing tools within ArcGis which gives access to them from the code) when you are using ArcGis, however as a matter of good habit, were I to export the Python script, it would be privy to have it incase the script was being run elsewhere on a computer that had access to the application.
I then set the environmental parameters, meaning that I was drawing my datasets from my data file on my desktop. Beneath this I set the boolean query to overwrite my outputs.

Accessing the toolbox database on ArcGis tool information online, I was able to get the code structure for each task: XY Coordinates, buffer and dissolve and typed them, adding the variables from my data into their requisite function location. Beneath each I requested it print what each code was doing, i.e. 'Adding XY coordinates...' and then print the 'get message' function which collected the data messages of each line of code operating and, in conjunction with their explanation of operation of code, aggregated them at the bottom of the cell after completing my results. 

The difficult issue with designing this code is whether or not to sabe the buffer shapefile output to the results folder or to the data folder. I decided that I would have it sent to the results folder on my computer. This meant that when I went to insert the variable into the dissolve code, I had to call it from the result file with its filepath as it was not in the data folder where I workspace environment was set. 
My rationale at having the buffer output reside in the results folder is that if this were for a client, I would want all aspects of my outputs in one file for ease of access. If I had to provide the map image with the buffer for each hospital, not dissolved, it would be more intuitive to have it with the other outputs in the results folder. 

Here is the dissolved buffer of the Austin, TX hospitals:

Messages:



Comments