0

I'd like to read from the attribute table of an intermediate raster generated by arcpy.sa.Combine:

combined = arcpy.sa.Combine(['raster1', 'raster2'])
arcpy.BuildRasterAttributeTable_management(combined)
data = [row for row in arcpy.da.SearchCursor(combined, ["VALUE", "COUNT"])]

The above code raises: RuntimeError: 'in_table' is not a table or a featureclass

Is there a way to access the RAT without saving the raster?

  • Try to create raster layer from it. – FelixIP Sep 28 '18 at 19:38
1

Try setting arcpy.env.workspace = 'in_memory', or the cursor will not know where to find the raster.

It could also be that combined is a raster object which the cursor cannot read. Try "saving" it to in_memory workspace:

combined.save(r"in_memory\outcombine2")
data = [row for row in arcpy.da.SearchCursor(r"in_memory\outcombine2", ["VALUE", "COUNT"])]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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