Wednesday, May 8, 2013

Using Python To Assist in Geoprocessing Operations

Using Python in Relation to Risk and Suitability Models


In this exercise, the programming language Python was used to automate some basic geoprocessing tasks in order to expose us to this powerful tool. By using Python, most functions of ArcGIS can be implemented, and even expanded upon. Stand-alone tool operation can be done, such as running Clip or Buffer, and iterations can also be run, like those used in ModelBuilder, to set tools to run multiple times. In this simple example, the sand mine locations used in the geocoding and network analysis blog entries were used, and a buffer was run five times, with each buffer being set to run 1,000 meters away from the previous operation. This is called a 'While Loop' and the code tells the program to keep running the script until the value is no longer true. A counter was used which would tell the function to stop running after the fifth buffer. In other words, a 1,000 meter buffer would run on the mine locations, and another buffer would run 1,000 meters from the first buffer, with the process repeated another three times. The Python script used to run the operation can be seen in Figure 1, and the results of the iteration can be visualized on the map in Figure 2.



Figure 1: Python script used to set up an interation buffer loop on the sand mine locations


Figure 2: Map visualizing the use of the Python script to set up an interation buffer loop on the sand mines

By using the Python script to automate functions that would otherwise have to be done individually,  a significant amount of time was saved running the tools. This saved time would have been beneficial to use in the previous exercise of creating the risk and suitability models of the frac sand mining. Iteration buffer loops around features of interest could be used to modify the look of either model, especially the risk model, so that it would look more pleasing to the eye. Remember that the Euclidean Distance operations run on the several categories in that raster made the final risk model look like it was full of circles. Implementing a loop cycle combined with a buffer would eliminate this issue, and the polygon feature classes generated could then be converted to a raster to produce a better looking map. Or, if one wanted to keep using the Euclidean Distance tool for the models, the Python script could be set up to cycle through the different feature classes that needed that particular tool run on it, and completely automate the process, instead of doing each Euclidean Distance function separately. The possibilities for this powerful component of ArcGIS are seemingly limitless, and it is now evident why many companies and organizations who hire GIS analysts want them to know Python. It can save time by automating processes that would otherwise have to be done manually, which translates into extra hours that can be used to complete other tasks.

No comments:

Post a Comment