suite1ae@cmich.edu

CalculateField_management

Discussion created by suite1ae@cmich.edu on Jun 8, 2012
Latest reply on Jun 8, 2012 by dkwiens
Hello,  I am attempting to loop through a process that will recalculate acres, select slivers and eliminate.  However, when I recalculate acres after the first eliminate I get the following error message: 

Failed to execute. Parameters are not valid.
ERROR 000732: Input Table: Dataset \\glarofas01\\elbows\\GreatLakes_NWI_Update\\MN\\EcognitionOutput\\Clip_Fix\\Elim\\Round1\\q3032sw does not exist or is not supported
Failed to execute (CalculateField).

The file that I am trying to pass into the Calculate Field function does exist.  Also, the process works when I do it in model builder and directly from the tool in ArcCatalog. Unfortunately, I have a large set of data to process and would like to automate it.  Any help would be greatly appreciated.

outtemp = "C:\\Workspace\\crap\\outtemp" 
outtempdat2 = "C:\\Workspace\\crap\\outtempdat2"
outtempdat3 = "C:\\Workspace\\crap\\outtempdat3"
for infile in qqlist:
    eliminate_file = elim_path + infile
    try_file = update_path + infile + "_singlepart.shp" 
    try:
        gp.CalculateField_management(try_file, "ACRES", "!SHAPE.AREA@ACRES!", "PYTHON", "")
        try:
            if infile not in fail_list:
                gp.MakeFeatureLayer_management(try_file,outtemp, )
                gp.OverWriteOutput = 1
                gp.SelectLayerByAttribute_management(outtemp, "NEW_SELECTION", "\"ACRES\" < 0.025 ")
                # Process: While ther are sliver continue through loop...
                if countdat > 0:
                    gp.Eliminate_management(outtemp, eliminate_file, "LENGTH", "", "")
                    gp.OverWriteOutput = 1
                    gp.CalculateField_management(eliminate_file, "ACRES", "!SHAPE.AREA@ACRES!", "PYTHON", "")
                    gp.MakeFeatureLayer_management(eliminate_file,outtempdat2,)
                    gp.SelectLayerByAttribute_management(outtempdat2,"NEW_SELECTION", query)
                    countdat = gp.GetCount_management(outtempdat2)
                    elim_count = 0
                    if countdat == 0:
                        try:
                            os.system("copy \"%s\" \"%s\"" % (outtempdat2, output_path + infile))
                        except:
                            fail_list.append(infile)
                            i = 0
                            while countdat > 0:
                                eliminate_file = eliminate_file + str(countdat)
                                gp.Eliminate_management(outtemp, eliminate_file, "LENGTH", "", "")
                                gp.CalculateField_management(eliminate_file, "ACRES", "!SHAPE.AREA@ACRES!", "PYTHON", "")
                                gp.MakeFeatureLayer_management(eliminate_file,outtempdat3,)
                                print gp.GetMessages(0)
                                gp.SelectLayerByAttribute_management(outtempdat3,"NEW_SELECTION", query)
                                countdat = gp.GetCount_management(outtempdat3)
                                elim_count = 0
                                if countdat == 0:
                                    try:
                                        os.system("copy \"%s\" \"%s\"" % (outtempdat3, output_path + infile))
                                    except:
                                        fail_list.append(infile)                        
                else:
                    if countdat == 0:  
                        try:
                            os.system("copy \"%s\" \"%s\"" % (outtemp, output_path + infile))
                        except:
                            fail_list.append(infile)
            else:
                fail_list.append(infile)
        except:
            fail_list.append(infile)
    except:
        fail_list.append(infile)
 

Outcomes