GIS Programming: Geoprocessing with Python
One of our tasks for this week's lab was to write a Python script using the Spyder IDE to execute the following geoprocessing objectives on the provided hospitals shapefile :
- Add XY Coordinates to the hospitals shapefile
- Create a 1000 meter buffer around the hospital feature
- Dissolve the hospital buffers into a separate, single feature
My thought process for completing these objectives is outlined in the following steps:
- First, I imported the ArcyPy package, set the workspace environment to my Data folder within the Module 3 folder (S:/GISProgramming/Module3/Data), and enabled geoprocessing outputs to be overwritten.
- For adding the XY coordinates to the hospitals shapefile, I ran the AddXY_management() tool using the hospitals shapefile as the input parameter. I then used the GetMessages() function to print out the messages from this tool.
- For adding the 1000 meter buffer around the hospitals, I ran the Buffer_analysis() tool using the hospitals shapefile as the input parameter, setting the output parameter to hosptials_buffer.shp, and setting the buffer distance to 1000 METERS. Just as with the previous tool, I used the GetMessages() function to print out the messages from buffer tool.
- Lastly, for dissolving the hospital buffers into a single, separate feature, I ran the Dissolve_managment() tool using the hospitals_buffer shapefile as the input parameter and setting the output to hospitals_buffer_disolved.shp within my Module 3 Results folder. Again, I used the GetMessages() function to print out the messages from this tool.
Below is a screenshot of my results after successfully executing my script:
Comments
Post a Comment