Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
2  
If it really does already exist you can try adding arcpy.env.overwriteOutput =True – valveLondon Dec 1 '12 at 0:50

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

share|improve this answer
    
thanks a lot - this hint finally solved my problem I have been working on for hours. Within my created python script an output folder should be specified to store a bunch of raster results. Setting it to Output created errors, now as I set it to Input it immediately worked. – the_chimp Mar 9 at 5:24

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

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.