I have a script that worked fine a month ago but I suspect due to some reconfiguring of my citrix profile by IT as part of a maintennance drill they changed something that affects my ability to create folders and file gdbs from a script. In this script, a for loop is used to create multiple clips of a three large line feature classes into smaller areas. I want the script to create a folder for each location and a generic Features.gdb within that folder and I thought this happens as part of the clip tool being called in the script.
Here is my code:
outputFolder = r"N:\Common\MapClips\CO_181" env.workspace = r"N:\Workspace\Updates_2017\gisdb\HERE_2017_Q1_3530_Recology2017Q1.gdb" env.overwriteOutput = True Cutter = r"N:\Common\MapClips\CO_181\Features.gdb\CO_181_Dissolve" Dough1 = r"N:\Workspace\Updates_2017\gisdb\HERE_2017_Q1_3530_Rec2017Q1.gdb\here_2017_q1_streets" Dough2 = r"N:\Workspace\Updates_2017\gisdb\HERE_2017_Q1_3530_Rec2017Q1.gdb\here_2017_q1_streets_alias" Dough3 = r"N:\Workspace\Updates_2017\gisdb\HERE_2017_Q1_3530_Rec2017Q1.gdb\here_2017_q1_streets_parity" fcs = [Dough1, Dough2, Dough3] with da.SearchCursor(Cutter, ["SHAPE@", "Fran"]) as rows: for row in rows: #1. create fgdb in outputFolder variable outGDB = os.path.join(outputFolder,"CO_" + row, "Features.gdb") geom = row# arcpy.CopyFeatures_management(geom, r"in_memeory\temp") for fc in fcs: out_feature_class = os.path.join(outputFolder, outGDB, row+ "_" + os.path.basename(fc)) print out_feature_class arcpy.Clip_analysis(fc,geom,out_feature_class) del fc del row print "Created " + out_feature_class
This throws the following error:
Traceback (most recent call last): File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 323, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 654, in run exec cmd in globals, locals File "N:\Python\Completed scripts\Ratto_Cal_Street_Update_Prep.py", line 3, in <module> import arcpy File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\analysis.py", line 56, in Clip raise e ExecuteError: ERROR 000210: Cannot create output N:\Common\MapClips\CO_181\CO_Nov\Features.gdb\Nov_here_2017_q1_streets Failed to execute (Clip).
I went and created the first output location manually:
And it worked in the first iteration and then bombed when it got to the next clip feature as there was not yet a folder or gdb created for it yet.
I know this worked fine for me before and I didn't have to manually create the folders and fgdbs. I can do that if necessary but I would prefer to have this process done automatically through the script.