This is the first large script we have had to write without a
template. The provided links were very helpful. They were a good starting place
to write my code from. I started by importing arcpy and the environment workspace.
I then made a variable for my input feature (hospitals.shp). This was then used
in the method to add XY coordinates. I checked the coordinates were added in
the ArcPro attribute table.
The second task was to created a 1,000m buffer around the hospital features. I drew a lot of my code from the linked example. I essentially created variables for all of the buffer tool options (what I would select from the ArcPro tool dropdown menus) and made them equal to my selections. I then put all my variables as the argument for the buffer method. This code ran correctly once but I got errors after that because the output file already existed. I did some research and added a line at the beginning of this code section allowing it to overwrite files.
The last section was to dissolve the hospital buffers into a single file. My method to write this code was similar to the last section. I made variables for input feature and output feature class, and selected my dissolve field. These all went into the dissolve method.
I struggled with adding the GetMessage() into the code. At first, I was confused on exactly what the instructions were asking me to do. I had to do some research online to figure out how the method worked. I realized I needed to add it into a print message. I wrote a print line with a string to indicate which section was running along with the GetMessages(). Below is an image of my script results:
Comments
Post a Comment