TransWikia.com

What might cause "ERROR 000728: Field does not exist within table" in this code?

Geographic Information Systems Asked by Arash on February 25, 2021

I have seen ERROR 000728 several times and I could never figure out why it happens.

Here is a snippet from my code:

str_Dissolve = arcpy.Dissolve_management(Intersect_str, "in_memory/str_Dissolve", "FID_Con_st", "", "MULTI_PART", "DISSOLVE_LINES") 

I do have a field named “FID_Con_st”.

There is no space in the field name and it doesn’t seem to be any refresh bug, because it persists after closing the script. These were possible causes suggested by an earlier Question and an ArcGIS Discussion Form Posting.

Are there other possible causes that anyone can suggest?

One Answer

Confirm that the field FID_Con_st exists immediately before your line of code tries to use it by running this test.

for field in arcpy.ListFields(Intersect_str):
    print field.name
str_Dissolve = arcpy.Dissolve_management(Intersect_str, "in_memory/str_Dissolve", ["FID_Con_st"], "", "MULTI_PART", "DISSOLVE_LINES")

My suspicion, from the fact that you are trying to write your output feature class to an in_memory workspace, is that the Intersect_str variable may be set to something already in memory - and there is no guarantee that a feature class held in memory has the basic set of fields you come to expect in a feature class stored in a file geodatabase.

For background on why I have suggested the in_memory workspace be considered a possible cause see the related bug NIM063795.

The test below shows that an in_memory workspace can be used with Dissolve so I think your question needs to be re-focussed on what you are using as your dissolve field and your code snippet does not explain where that is coming from.

import arcpy

if arcpy.Exists("C:/Temp/Test.gdb"):
    arcpy.Delete_management("C:/Temp/Test.gdb")

if arcpy.Exists("in_memory"):
    arcpy.Delete_management("in_memory")

arcpy.CreateFileGDB_management("C:/Temp","test","CURRENT")
arcpy.CreateFishnet_management("C:/Temp/test.gdb/fishnetPolys","0 0","0 1","1","1","2","2","#","NO_LABELS","#","POLYGON")
arcpy.AddField_management("C:/temp/test.gdb/fishnetPolys","DissolveField","TEXT","#","#","#","#","NULLABLE","NON_REQUIRED","#")
arcpy.CalculateField_management("C:/temp/test.gdb/fishnetPolys","DissolveField","'Any Value To Dissolve On'","PYTHON_9.3","#")
arcpy.CopyFeatures_management("C:/temp/test.gdb/fishnetPolys","in_memory/fishnetPolysInMemory","#","0","0","0")
print "Try dissolving with input and output both on disk ..."
arcpy.Dissolve_management("C:/temp/test.gdb/fishnetPolys","C:/temp/test.gdb/fishnetPolysDissolved","DissolveField","#","MULTI_PART","DISSOLVE_LINES")
print "Worked!"
print "Try dissolving with input in memory and output on disk ..."
arcpy.Dissolve_management("in_memory/fishnetPolysInMemory","C:/temp/test.gdb/fishnetPolysDissolvedFromMemory","DissolveField","#","MULTI_PART","DISSOLVE_LINES")
print "Worked!"
print "Try dissolving with input and output both in memory ..."
arcpy.Dissolve_management("in_memory/fishnetPolysInMemory","in_memory/fishnetPolysDissolvedInMemory","DissolveField","#","MULTI_PART","DISSOLVE_LINES")
print "Worked!"
print "Try dissolving with input on disk and output in memory ..."
arcpy.Dissolve_management("C:/temp/test.gdb/fishnetPolys","in_memory/fishnetPolysDissolvedToMemory","DissolveField","#","MULTI_PART","DISSOLVE_LINES")
print "Worked!"

Answered by PolyGeo on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP