GIS 5103 - Module 4
In this module, I was tasked with creating a script in Spyder that will take one existing shapefiles of hospitals, and will perform the following in sequential order:
1) Add XY data, meaning a column for X and a column for Y, and populate them using information in the original point file which lacked XY data.
2) Create a buffer of 1000 meters around the hospitals.
3) Dissolve overlapping buffers into one feature.
The script below shows successful completion of these steps in the Spyder console.
1) Add XY data, meaning a column for X and a column for Y, and populate them using information in the original point file which lacked XY data.
2) Create a buffer of 1000 meters around the hospitals.
3) Dissolve overlapping buffers into one feature.
The script below shows successful completion of these steps in the Spyder console.
I had some issues running the script at first. Due to syntax errors, I was struggling to get the XY step to run. I thought the issue was due to corrupted file paths, and spent some time trying to debug in the wrong area. The issue was simple to fix as it was just some extra quotations marks, but it took some looking to catch.
Please see my process summary for more information on my process.
1.
I was getting an error that my file path is not valid, “ExecuteError:
Failed to execute. Parameters are not valid. ERROR 000732: Input Data: Dataset
Hospitals does not exist or is not supported. I struggled
to get past this error with step 1 of part 2, so I decided in the interest of
time to see if I could bypass it and come back later, using a try except
statement, which I have left in my final code even though I have resolved the
issue. (The issue turned out to be a simple syntax error involving misplaced
quotations.”
2. To add the XY, I defined the folder path, my input data set being the original
hospitals.shp and my output being a file to be created through the program,
hospitalsXY.shp.
3. To create the buffers layer, the only inputs I added were the
input data, which is the XY file just created, the output file path with the
name for the file to be created, and the distance of 1000 Meters.
4. To create the dissolved layer, the only input I specified were
the input data set, the newly created buffers layer, and the output path and
file name. I did not add any other features that would have impacted the
attribute table, though depending on final use of this file, may have been
necessary.
5. Because the script was being run multiple times, at the very
top of the script with the import arcpy functions, I added that the arcpy
environment overwrite outputs, so that things would be saved along the way as I
worked on creating the script.
Comments
Post a Comment