Monday, June 22, 2015

Python and Geoprocessing

 
 
This week's lesson focused on writing Python script for geoprocessing tools. While these tools can be used in ArcMap, writing custom scripts can increase the potential of tools. 

The lecture, readings, and exercise that prepared us to write our own script included material on importing Arcpy modules, classes, functions and tools.  We practiced setting a workspace, creating variables, working with parameters, learning syntax for commonly used code, working with messages, and using a few geoprocessing tools.  Then we wrote our own geoprocessing code in order to create a 1000 meter buffer around hospitals, dissolving the overlapping perimeter lines.  We also set the XY coordinates for each hospital. After each geoprocessing tool was run, a line of code asked for a message to be printed, allowing the user to see if each step had run successfully. The image above shows that the script ran successfully in PythonWin.  In ArcMap, running the script produced the new shapefiles and added them as layers to the map.

This week's reading assignment was Chapter 5, and for me it was the most essential one so far, giving me several "ah-ha" moments as I finally understood some of the concepts and language that have been frustrating me up to this point.  Up until now, I didn't really get how the code we were writing actually made things run.  Things are clicking a bit better now.

No comments:

Post a Comment