Thursday, June 19, 2014

GIS 5103 Module 5: Geoprocessing with Python


The whole point of this course is to learn how to use Python to geoprocess data using the tools of ArcGIS.  With module 5 we are now getting familiar enough with the syntax of Python to use it to accomplish geoprocessing tasks.  These tasks may be simple, but they will be the building blocks for more complex tasks in future modules.

Our assignment for the week was simple yet required some thought and planning to complete correctly.  Our script was required to add XY coordinates to a layer, create a 1000 meter buffer around the features of that layer, then create a new buffer layer dissolved into a single feature.  The standalone script also needed to print the messages of the tools in the Interactive Window (see screenshot above).  To run more than once, we also needed to include code to allow the overwriting of previous data.

To add XY coordinates to the hospitals layer, I consulted ArcGIS help on the proper syntax for the AddXY_management tool.  As described in the help file, I also used the Copy_management tool to first create a new copy of the hospitals shapefile to which was then appended XY coordinates with the AddXY tool.  I also used this tool to experiment with creating variables for the input parameters as described in the exercise.

The rest of the script was relatively simple to write.  The only issue I ran into was the failure of the script to overwrite previous data.  After some time fiddling with the script, I realized ArcMap was open in the background.  Closing ArcMap allowed the script to run and overwrite without error.

No comments:

Post a Comment