This week's module involved creating a Python script to use geoprocessing tools. We had to create a script that added XY coordinates, created a 1000 meter buffer, and dissolved the buffer in a shapefile.
The screenshot posted above is the output of the script, created using the arcpy.GetMessages() function. The module required us to overwrite the output shapefiles, for which I used the arcpy.env.overwriteOuput function.
For this script I first imported the arcpy module, then I set up the workspace using env.workspace and enabled overwrite. In order to add XY coordinates to the shapefile I first used Copy_management() to make a copy of the hospitals shapefile so the original shapefile stays unaltered. I then used AddXY_management() to add XY coordinates to the new hospitals_XY shapefile. To add the 1000 feet buffers, I used analyisis.Buffer() to add the buffers around the hospitals_XY shapefile. For the final part of the script, I used management.Dissolve() to dissolve the buffers.
No comments:
Post a Comment