-1

I have a python script which dies after the first iteration. It dies on the second feature class to coverage. This also happened in modelbuilder, which is why I went to python hoping it would go away. I can create the coverage on the layer that crashes the script in the standalone tool, but once in the script, after the first iteration, it dies. It makes me think that there is something being held on to in memory by the script or modelbuilder that I am not aware of.

I have tried repairing geometry of the input dataset; ensuring it is singlepart; name chages. None has worked.

View image for error in image. It says invalid topology, but it works fine standalone.

enter image description here

import arcinfo, arcpy, os, sys
from arcpy import env
print 'Starting....'
env.OverWriteOutput = True
arcpy.SetProduct("ArcInfo")
import datetime
import time
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
print st

tbx = arcpy.ImportToolbox(r"C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Coverage Tools.tbx", "COVG")
SDE = "C:\\Users\\david\\AppData\\Roaming\\ESRI\\Desktop10.1\\ArcCatalog\\p747.sde"
AVI = r"C:\david\delete\AVI.shp"
#AVI = "G:\\ALPAC\\Projects\\P747\\3_Landbase\\Processing\\AVI\\AVI_20141216_Only_polynum.shp"
FMUs = r"C:\david\delete\fmus2.shp"
#FMUs = r"\\silver\\clients\Projects\P747\3_Landbase\LB1\FileGeodatabase\All_Data\All_Data.gdb\ALPAC_Data\Administrative_FMUs"
GDB1 = "\\\\silver\\clients\\Projects\\P747\\3_Landbase\\LB1\\Temp\\"
FCView = "\\\\silver\\clients\\Psrojects\\P747\\3_Landbase\\LB1\\TEMP\\FCView.lyr"
LayerU = r"G:\Projects\P747\3_Landbase\LB1\Multiunion\TEMP\Union_Fwrd"
OutLOC = "\\\\silver\\clients\\Projects\\P747\\3_Landbase\\LB1\\multiunion\\m_20150129\\"
TableView = "\\\\silver\\client\\Projects\\P747\\3_Landbase\\LB1\\Temp\\Tableview.lyr"

FieldMappings = arcpy.FieldMappings()
FieldMap1 = arcpy.FieldMap()
#arcpy.RepairGeometry_management(FMUs)
if arcpy.Exists(FCView):
    arcpy.Delete_management(FCView)

arcpy.MakeFeatureLayer_management(FMUs, FCView)

FieldMap1.addInputField(FMUs, 'FMU_NAME')
FieldMappings.addFieldMap(FieldMap1)

r = 1
for row in arcpy.SearchCursor(FCView):

    objectid = str(row.getValue("FMU_NAME"))
    #print '"FMU_NAME"= {}'.format(objectid)
    print 'Working on ' + objectid

    FMUNAME = GDB1 +  "FMU_" + objectid + ".shp"
    AVINAME = GDB1 + "AVI_" + objectid + ".shp"
    OUTCOV = OutLOC+ "MU_" + objectid
    OUTCOVPOLY = OutLOC+ "MU_" + objectid + " POLYGON"

    if arcpy.Exists(FMUNAME):
        arcpy.Delete_management(FMUNAME)
    if arcpy.Exists(AVINAME):
        arcpy.Delete_management(AVINAME)
    if arcpy.Exists(OUTCOV):
        arcpy.Delete_management(OUTCOV)
    if arcpy.Exists(GDB1+ "MUa_" + objectid):
        arcpy.Delete_management(GDB1+ "MUa_" + objectid)
    if arcpy.Exists(GDB1+ "FMU_" + objectid):
        arcpy.Delete_management(GDB1+ "FMU_" + objectid)
    if arcpy.Exists(TableView):
        arcpy.Delete_management(TableView)
    if arcpy.Exists(GDB1 + "AVICV_" + objectid):
        arcpy.Delete_management(GDB1 + "AVICV_" + objectid)
    if arcpy.Exists(GDB1 + "AVIa_" + objectid + ".shp"):
        arcpy.Delete_management(GDB1 + "AVIa_" + objectid + ".shp")

    arcpy.SelectLayerByAttribute_management(FCView, "NEW_SELECTION", '"FMU_NAME"=' + "'" + objectid + "'")

    print 'Creating FMU shape and coverage for clipping'

    arcpy.FeatureClassToFeatureClass_conversion(FCView , GDB1, "FMU_" + objectid, "#", FieldMappings)
    arcpy.FeatureclassToCoverage_conversion(FMUNAME + " POLYGON", GDB1 + "FMU_" + objectid, "", "DOUBLE")

    print 'Running clips'

    arcpy.Clip_COVG(LayerU, GDB1 + "FMU_" + objectid, GDB1+ "MUa_" + objectid)
    arcpy.Clip_analysis(AVI, FMUNAME, GDB1 + "AVI_" + objectid)

    #print 'Repairing geometry'

    #arcpy.RepairGeometry_management(GDB1 + "AVI_" + objectid + ".shp")

    print 'Turn AVI into coverage'

    #ERROR OCCURS HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    arcpy.FeatureclassToCoverage_conversion(AVINAME + " POLYGON", GDB1 + "AVICV_" + objectid, "", "DOUBLE")

    print 'Unioning the ' + objectid + " datasets"

    arcpy.Union_COVG(GDB1 + "AVICV_" + objectid, GDB1+ "MUa_" + objectid, OutLOC + "MU_" + objectid)

    #print 'Running multi-part to single-part'

    #arcpy.MultipartToSinglepart_management(GDB1 + "AVIa_" + objectid + ".shp", GDB1 + "AVI_" + objectid)

    print 'Calculating fields'

    arcpy.MakeTableView_management(OUTCOV +'\\polygon', TableView)
    arcpy.AddField_management(TableView, "MKey", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    arcpy.CalculateField_management(TableView, "MKey", "( " + str(r) + " * 1000000 ) + !FID!", "PYTHON", "")
    arcpy.AddField_management(TableView, "AreaHA", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    arcpy.CalculateField_management(TableView, "AreaHA", "!shape.area@hectares!", "PYTHON", "")

    print 'Deleting fields'

    arcpy.DeleteField_management(TableView, "U20#;U20-ID;U19#;U19-ID;U18#;U18-ID)

    #print 'Deleting fields'
    #if arcpy.Exists(SDE + objectid + "_tables_v2"):
    #    arcpy.Delete_management(SDE + objectid + "_tables_v2")

    #print 'Table to table'
    #arcpy.TableToTable_conversion(TableView, SDE2, objectid + "_tables_v2")

    #print 'Deleting fields'
    #arcpy.DeleteField_management(TableView, "FEATURE_TY;NAME;TS_BUFF;PLOT_TYPE;DISP_NUM;DISP_TYPE;LANDBASE;RIVBRK;FMU_NAME;MOSA;SLOPE;FIRE_NUMBE;BURNCODE;BURN_CLASS;YEAR;RFMA_NAME;HYD_FEAT;CRPRO_NAME;TYPE;PPA_STAT;DIDS_NUM;DIDS_TYPE;ID;WTRSHED;FN_TYPE;FN_NAME;MUNIC_TYPE;MUNIC_NAME;FMA_STATUS;FEATURE_NA;DFA_STATUS;HY_DIST;HY_SRCE;HY_FEATURE;POLYGON;OWNER_1;STATUS;OWNERSHIP;CATEGORY;OPEN_NUM;COWPER_LOS;RSIID;POLY_NUM")

    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
    print st

    print 'Next....'

    r += 1

python 2.7, Arcinfo license and 10.2 Arc

12
  • For that error message my first thought is always a lack of memory - see gis.stackexchange.com/a/90531 - also, it is far better to include error messages as text rather than pictures so that they can be searched for. It looks like you have run it at the DOS prompt which may make that hard to copy/paste so I would try running it from IDLE instead.
    – PolyGeo
    Commented Feb 1, 2015 at 3:47
  • I can do that for sure with the image. As for your comment, I think something like that is happening; as if after the first iteration, the memory is held onto. Is there a way to dump everything after the iteration?
    – D_C
    Commented Feb 1, 2015 at 3:49
  • Some people have suggested using Python's subprocess (e.g. geonet.esri.com/thread/49275) and I started to investigate that once a few years ago but I think I found that upping the RAM solved my issues and so I abandoned that effort.
    – PolyGeo
    Commented Feb 1, 2015 at 3:56
  • I've got 16GB and 64 bit. I have access to a virtual machine on our network with 48GB and 64 bit but the modelbuilder version of this process crashed on it too.
    – D_C
    Commented Feb 1, 2015 at 4:02
  • You may need to consider the approach that I suggested on another ERROR 999999 at gis.stackexchange.com/a/92421 - it is certainly what I would have pursued if that error became a showstopper for me.
    – PolyGeo
    Commented Feb 1, 2015 at 4:05

1 Answer 1

1

According to the help file the in_features should be a list of featureclasses and type.

Try changing this line

arcpy.FeatureclassToCoverage_conversion(AVINAME + " POLYGON", GDB1 + "AVICV_" + objectid, "", "DOUBLE")

to

arcpy.FeatureclassToCoverage_conversion([[AVINAME , "POLYGON"]], GDB1 + "AVICV_" + objectid, "", "DOUBLE")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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