Hi all,
I've got a Python-script (sample below) which appends all points from a list of Route Event Layers into one in_memory feature class. Before the append, I need to calculate some field, using CalculateField.
However, CalculateField is extremely slow (say 5min for 5000 records).
I also tried the UpdateCursor, but same lack of performance.
Anyone a suggestion how to speed up my process in ArcGIS 9.3?
Thanks,
Koen
allPoints = "in_memory/allPoints"
gp.CreateFeatureClass("in_memory","allPoints","POINT")
gp.AddField(allPoints,"ORIGID","LONG")
gp.AddField(allPoints,"ALLELEV","DOUBLE",15,6)
gp.AddField(allPoints,"ORIGFC","TEXT",50)
i = 1
for item in elevationPointList:
desc = gp.Describe(item)
oidFieldName = desc.OidFieldName
flds = gp.ListFields(item)
origIDExist = False
allHExist = False
origFcExist = False
for fld in flds:
if fld.Name == "ORIGID":
origIDExist = True
if fld.Name == "ALLELEV":
allHExist = True
if fld.Name == "ORIGFC":
origFcExist = True
if origIDExist == False:
gp.AddField(item,"ORIGID","LONG")
if allHExist == False:
gp.AddField(item,"ALLELEV","DOUBLE",15,6)
if origFcExist == False:
gp.AddField(item,"ORIGFC","TEXT",50)
writeLog(item + "0 " + dt.now().ctime())
gp.CalculateField(item,"ORIGID",'[' + oidFieldName + ']')
if item.count("_events") > 0:
gp.CalculateField(item,"ORIGFC",'\"' + item.replace("lyr_","") + '\"')
gp.CalculateField(item,"ALLELEV",'[TOPELEV]')
else:
gp.CalculateField(item,"ORIGFC",'\"' + getBaseName(item) + '\"')
gp.CalculateField(item,"ALLELEV",'[ELEV]')
writeLog(item + " " + dt.now().ctime())
gp.Append_Management(item,allPoints,"NO_TEST")
gp.DeleteField_Management(item,"%s;%s;%s" %("ORIGID","ALLELEV","ORIGFC"))