Module 4: Geoprocessing
In this weeks module the focus was on geoprocessing tools, creating our own ModelBuilder and toolboxes. The first portion of the assignment was using the ModelBuilder to clip sols within the basin shapefile, select a specific attribute within the soils shapefile, and erase the "Not prime farmland" within the soils shapefile. Within the ModelBuilder the you can drag in your data and geoprocessing tools. These tools are similar as ones that I have used within the maps. The ModelBuilder is important because you can create what you want done all at once instead of each step separately. In the image below it shows how I added the basin and soils shape file. Next added in the clip analysis tool where I said I wanted the soils only within the basin shapefile. Which creates the shapefile which I called soil_Clip. Then to erase the "Not prime farmland" portion I needed to add the Select analysis tool which I created a script. Lastly, this created Soils_Selected.shp.
This image below shows what the ModelBuilder produced which was all the areas that were not apart of the "Not prime farmland" shapefiles.
The next portion of this module was writing script that adds XY coordinates, creates a 1000 meter buffer, and dissolve the buffers into a single feature for the hospitals shapefile. When designing the script that adds the XY coordinates, buffers, and dissolve the hospital shapefile I needed to make sure there is arcpy and env workspace. The workspace is the location of where the data is coming from to add the information to the shapefile. Next, I made sure to overwrite the output features so the code could be done repeatedly. The first portion of the code was the XY coordinates on the shapefile by creating the shapefile as the in_features. To make sure the shapefile gets the XY coordinates the code needs to be “arcpy.management.AddXY(in_features)”. For the buffer portion I needed to write “arcpy.Buffer_analysis” Within this code I need to make sure to put in the buffer zone and where I want the shapefile to go which was the results tab in Module. Lastly, for the dissolving portion it is the same code as the buffer analysis, but I needed to make sure to add two open string portions and one that says ‘ALL’. This will make sure all the areas that overlap dissolve and create a whole new shapefile. If I did not want to create a new shapefile, I could name it the same shapefile as above. Another thing that needed to be added was the GetMessages() function so you can see the start time and if the script was successful in running. I put this in after the the other print option. The code was written as "print(arcpy.GetMessages())". Within ArcGIS Pro you do not necessarily need to add arcpy but I still added “import arcpy” in case the script runs in IDLE. Also, to make sure things are overwritten you need to make sure the box in clicked in the options tab under geoprocessing and write the code “env.overwriteOutput = True”. Lastly, to make a space within your script you can use “\n” within the print portion of the script. The image below is the result of the script that I wrote to add the XY coordinates, 1000 meter buffer, and dissolve the buffer for the hospitals shapefile.
This weeks module was very useful because it is able to learn how to use ModelBuilder to make shapefiles all at once instead of one at a time. Also, I learned how to do Batch processing that can help me do a lot of data all at once. Lastly, I was able to learn how to create a script that can add XY coordinates, add a buffer, and dissolve that buffer instead of doing it through the geoprocessing tools individually.



No comments:
Post a Comment