I have a series of buffer polygons that I need to perform a spatial join on to get overall counts within the buffers. I can do this by copy and pasting the spatial join script over and over and just swapping out the buffer layer/output file name.
However, I'd like to figure out a simple loop that will go through all the buffers at once. I attempted a code myself but I'm not versed enough to figure out the solution to the error I'm getting. Any tips?
Buffer_5mi = "G:\\Admissions\\GBD\\GBD\\Admissions.gdb\\Buffer_5mi"Buffer_10mi = "G:\\Admissions\\GBD\\GBD\\Admissions.gdb\\Buffer_10mi"Targets = [Buffer_5mi, Buffer_10mi]Freshmen_Admitted = "Freshmen_Admitted"for Target in Targets: output = "G:\\Admissions\\GBD\\GBD\\Admissions.gdb\\admitted%s" % Target arcpy.SpatialJoin_analysis(Target, Freshmen_Admitted, output, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "INTERSECT", "", "")This is the error I'm getting. I understand why the error is popping up, what I dont know is the solution to it.
Runtime error Traceback (most recent call last): File "", line 9, in File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 471, in SpatialJoin raise e ExecuteError: ERROR 000210: Cannot create output G:\Admissions\GBD\GBD\Admissions.gdb\admittedG:\Admissions\GBD\GBD\Admissions.gdb\Buffer_5mi Failed to execute (SpatialJoin).
أكثر...
However, I'd like to figure out a simple loop that will go through all the buffers at once. I attempted a code myself but I'm not versed enough to figure out the solution to the error I'm getting. Any tips?
Buffer_5mi = "G:\\Admissions\\GBD\\GBD\\Admissions.gdb\\Buffer_5mi"Buffer_10mi = "G:\\Admissions\\GBD\\GBD\\Admissions.gdb\\Buffer_10mi"Targets = [Buffer_5mi, Buffer_10mi]Freshmen_Admitted = "Freshmen_Admitted"for Target in Targets: output = "G:\\Admissions\\GBD\\GBD\\Admissions.gdb\\admitted%s" % Target arcpy.SpatialJoin_analysis(Target, Freshmen_Admitted, output, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "INTERSECT", "", "")This is the error I'm getting. I understand why the error is popping up, what I dont know is the solution to it.
Runtime error Traceback (most recent call last): File "", line 9, in File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 471, in SpatialJoin raise e ExecuteError: ERROR 000210: Cannot create output G:\Admissions\GBD\GBD\Admissions.gdb\admittedG:\Admissions\GBD\GBD\Admissions.gdb\Buffer_5mi Failed to execute (SpatialJoin).
أكثر...