Use the add geometry tool:
arcpy.AddGeometryAttributes_management("featureNeedsShape", "AREA")
This will add the field "POLY_AREA" to your in_memory feature.
Add Geometry Attributes (Data Management)—ArcGIS Pro | Documentation
Looks like this issue is not resolved for 10.5.1 too. I had to do the similar thing of creating new field and calculating lengths. But its simpler to just get the attribute as is. I think ESRI has to look into fixing this, especially when in-memory is used for faster processing.
Yes, its status is still "Open: Assigned". I would suggest contacting Esri support and adding your information to this bug. If more people complain about it, its priority will go up.
Still seeing this behavior at 10.3.1, doesn't seem like ESRI is going to fix it ...
Thanks KenHowever, for me it is not restricted to background geoprocessing.- Graeme
ESRI has issued Bug NIM063795 about this behavior. It occurs when the background processing is enabled.
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","1","1","#","NO_LABELS","#","POLYGON") fcs = arcpy.SearchCursor("C:/Temp/test.gdb/fishnetPolys") for fc in fcs: print fc.Shape_Area print "Above came from Shape_Area field of polygon on disk" del fc,fcs arcpy.CopyFeatures_management("C:/Temp/test.gdb/fishnetPolys","in_memory/fishnetPolysInMemory") arcpy.CopyFeatures_management("in_memory/fishnetPolysInMemory","C:/Temp/test.gdb/fishnetPolysBackOnDisk") fcs = arcpy.SearchCursor("C:/Temp/test.gdb/fishnetPolysBackOnDisk") for fc in fcs: print fc.Shape_Area print "Above came from Shape_Area field of polygon copied from disk to in_memory and back to disk" del fc,fcs fcs = arcpy.SearchCursor("in_memory/fishnetPolysInMemory") for fc in fcs: print fc.Shape_Area print "Above came from Shape_Area field of polygon copied from disk to in_memory - but you should see error trying to access it" del fc,fcs
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.