0

My code is supposed to clip features within a temporary directory, project them and place them into a specific feature dataset within a geodatabase. Then the code goes back and deletes the temporary files in the temporary directory.

The code runs through a list to do this. The first iteration through works flawlessly but when the second iteration begins I receive the following error:

Traceback (most recent call last): File "Q:\Admin\AOI_Generator\Scripts\Create_AOI_v1.1_Pick.py", line 219, in arcpy.Project_management(temp + '\' + fc + "_" + ds + ".shp", data + "\" + ds + "\" + fc, outCS) File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 7822, in Project raise e ExecuteError: ERROR 999999: Error executing function. The table already exists. Failed to execute (Project).

I already know that the error occurs during the project_management, I am just unsure why it happens.

Please see the code below.

for buff, ds in n_list:
    def listFcsInGDB(gdb):
            env.workspace = gdb
            fcs = []
            for fds in arcpy.ListDatasets('','feature') + ['']:
                    for fc in arcpy.ListFeatureClasses('','',fds):
                            fcs.append(os.path.join(fds,fc))
            return fcs
    fcs = listFcsInGDB(gdb)
    for fc in fcs:

            arcpy.Clip_analysis(fc,r"Q:\\Admin\\AOI_Generator\\Shapefiles\\Buffer\\" + buff, temp + '\\' + fc + "_" + ds)
            arcpy.Project_management(temp + '\\' + fc + "_" + ds + ".shp", data + "\\" + ds + "\\" + fc, outCS)
            arcpy.Delete_management(temp + '\\' + fc + "_" + ds + ".shp")
    del fcs
1

I'm not sure I understand what you're trying to do, so I refactored the code a bit. Is this what you're trying to do?

def listFcsInGDB(gdb):
    env.workspace = gdb
    fcs = []
    for fds in arcpy.ListDatasets('','feature') + ['']:
        for fc in arcpy.ListFeatureClasses('','',fds):
            fcs.append(os.path.join(fds,fc))
    return fcs


fcs = listFcsInGDB(gdb)

for buff, ds in n_list:
for fc in fcs:
    arcpy.Clip_analysis(fc,r"Q:\\Admin\\AOI_Generator\\Shapefiles\\Buffer\\" + buff, temp + '\\' + fc + "_" + ds)
    arcpy.Project_management(temp + '\\' + fc + "_" + ds + ".shp", data + "\\" + ds + "\\" + fc, outCS)
    arcpy.Delete_management(temp + '\\' + fc + "_" + ds + ".shp")
del fcs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.