1
arcpy.AddField_management("in_memory/originalfc","ALPHABET","TEXT",1)
arcpy.Select_analysis("in_memory/originalfc","in_memory/A","attr<=0")
arcpy.CalculateField_management("in_memory/A","ALPHABET",'"A"',"PYTHON")
arcpy.Select_analysis("in_memory/originalfc","in_memory/B","attr>0")
arcpy.CalculateField_management("in_memory/B","ALPHABET",'"B"',"PYTHON")
arcpy.Merge_management(["in_memory/A","in_memory/B"],"in_memory/merged")

When the merge executes I get an error 001156 on OID 1 that says i can't write value 'A' to output field ALPHA.

If I try to append one to the other I get the same error. They were originally the same feature class why won't they go back together?

6
  • To which line does the error refer? The CalculateField or the Merge?
    – Tom
    Commented Jan 24, 2019 at 17:42
  • To the merge line
    – jtgis
    Commented Jan 24, 2019 at 17:53
  • 2
    If you used an expression in CalculateField you could avoid needing to split and re-merge. Something like arcpy.CalculateField_management("in_memory/originalfc","ALPHA",'"A" if !attr! <= 0 else "B"',"PYTHON")
    – mikewatt
    Commented Jan 24, 2019 at 18:16
  • 2
    Does it work when performed in a regular workspace like a file geodatabase?
    – PolyGeo
    Commented Jan 24, 2019 at 19:16
  • @Polygeo I have the same type of issue. When I am working with a regular file geodatabase merging works fine, when I am working with in memory workspace I get the same error as above..
    – GeoF
    Commented Jul 9, 2021 at 9:02

2 Answers 2

1

IN_MEMORY is a sort of simplified "geodatabase" but obviously in memory not on a disk. Now the important thing to appreciate is that it is like a geodatabase and thus honours the many specification, but not all, of a geodatabase.

I believe you have been unlucky enough to have chosen a geodatabase RESERVED field name, ALPHA. Suggest you call it something else like "myALPHA".

1

I got this error again and the reason it is coming up for me has to do with domains and in_memory feature classes and combining datasets in arcpy.

Example:

FeatureClass1 has attribute [NAME] with a coded value of "MR" and the domain shows "Mister" (that fc was a selection from a larger dataset and the domain assigned in the gdb carried over to the in_memory)

FeatureClass2 has attribute [NAME] with a value of "MR" no domain attached

If I merge the two I get error 001156. If I append FeatureClass1 to FeatureClass2 I get error 001156.

But if I append FeatureClass2 to FeatureClass1 it works!

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.