Sunday, June 30, 2013

GIS Programming, Lab 5: Geoprocessing with Python

This week in lab, we learned about geoprocessing with Python.  I found this lab to be a little stressful, but very rewarding once I was able to figure it out.  The outline of it was to create a script that would add XY coordinates to the hospitals shapefile, create a 1000 meter buffer around each hospital point and then dissolve the buffer layer.  Below is a screenshot of the Interactive Window using PythonWin once my code was successfully run.



First, I added my comments to the script.  Those included my name, the date, the script name and a brief description of what the end result should turn up.  I imported arcpy and set the environments.  I made sure I was able to run the script more than once using overwriteOutput.  The next step was to use the AddXY tool.  I used the Help section of ArcGIS to look at a sample code and syntax for the AddXY function.  After that, I turned, once again, to the Help section to look at sample code and syntax for the Buffer tool.  Here I needed to write a code that would create a 1000 meter buffer around each hospital point.  Once that was done, I needed to dissolve the buffers together.  Using the ArcGIS Help section, I reviewed sample code and the syntax for the dissolve function.  Finally, I made sure that the comments appeared after each step of code, letting me know it was run successfully.

This lab definitely helped me get a better grasp and understanding of using the tools in Python.

No comments:

Post a Comment