0

I need to clip all of the feature classes in the .gdb to a layer then add the results to a results dataset. However it returns the error.

Error 000210:Cannot create output C:...gdb\FC_Results\tranterm Failed to execute.

How do I set the output parameter of clip to create a featurename_clip output for each feature?

import arcpy
import os
arcpy.env.workspace = "C:/Student/WashingtonDC.gdb"
out_workspace = "C:/Student/WashingtonDC.gdb/FC_Results"
ClipFC = "C:/Student/WashingtonDC.gdb/citylim"
arcpy.env.overwriteOutput = True
ListFC = arcpy.ListFeatureClasses()
for FC in ListFC:
    output = os.path.join(out_workspace, FC)
    arcpy.Clip_analysis(FC,ClipFC,output,"",)
  • Do you already have a feature class dataset named "FC_Results" in the WashintonDC geodatabase? If so, are you positive that all the feature classes you are trying to clip have the same spatial reference as that feature class dataset? – mr.adam Apr 21 '15 at 16:51
  • Yes I added the dataset through arcCatalog and it has the same spatial reference. The real question I have is how to change the output parameter of clip to be inFC_clip. to avoid the name problem. – Ilus Apr 21 '15 at 16:54
  • It's interesting that you get that error even though you have overwriteOutput = True – mr.adam Apr 21 '15 at 17:02
  • 1
    No one has stated explicitly why this fails, so this is just for future reference. The key here is that the inputs and intended outputs will be in the same geodatabase. And have the same name. You can't duplicate a name within the same geodatabase, they need to be unique. – DWynne Apr 30 '15 at 0:57
  • Even if the feature classes are in separate feature datasets. – user2856 Jun 17 '15 at 23:02
1

I'm pretty sure that FC will work as a string, but if you need to, change it to str(FC). At this point, you can use basic python string operations.

You want:

output = os.path.join(out_workspace, FC + "_clip")

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.