Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am having trouble running a script tool that I just created in Arc 10.1. The script runs fine in PythonWin, but when I create a script tool with it, the tool seems to not want to accept folders or geodatabases as its output workspace. I have the output parameter (argument) set as both an output and a workspace in the script tool, but it still keeps giving me an error that the "Dataset.....already exists"

I'm a new user, so I can't post a picture, but the error is 000725

Here is my script, if that helps out.

import arcpy
#allow for overwrites
arcpy.env.overwriteOutput = True

#set the workspace
inWorkspace = arcpy.GetParameterAsText (0)

#set the erase feature
eraseFeature = arcpy.GetParameterAsText (1)

#set the output workspace
outWorkspace = arcpy.GetParameterAsText (2)


#get a list of all the features in the workspace
arcpy.env.workspace = inWorkspace
featureClassList = arcpy.ListFeatureClasses()

try:

    #loop through all of the features in the workspace
    for featureClass in featureClassList:

        #construct the output path
        outEraseFeature = outWorkspace + "\\erase_" + featureClass

        #perform erase
        arcpy.Erase_analysis(featureClass, eraseFeature, outEraseFeature)

        arcpy.AddMessage("Wrote clipped file " + outEraseFeature + ". ")
        print "Wrote clipped file " + outEraseFeature + ". "

except:

    # Report if there was an error
    arcpy.AddError("Could not erase feature classes")
    print "Could not erase feature classes"
    print arcpy.GetMessages()
share|improve this question
1  
If it really does already exist you can try adding arcpy.env.overwriteOutput =True –  valveLondon Dec 1 '12 at 0:50

2 Answers 2

It is for your own protection. To not get that error, you need to enable this option:Overwrite Outputs.

Alternately, change your Output_Workspace to an input parameter rather than an output parameter.

share|improve this answer

I actually found out that if I changed the direction of the output workspace from 'output' to 'input', the script ran without an error.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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