I'm trying to do a for cycle to calculate standard deviation and mean for each raster in a list and after that to do a mathematical operation between them. Can someone help me to understand what is the problem?
ws2 = r"C:\Users\Elisa\Model_Builder\passo_5_6_7_8\output\raster_tagliati_su_flowacc"
v_name_sc_img = r"C:\Users\Elisa\Model_Builder\passo_5_6_7_8\output\outliers\{0}_out1.img"
arcpy.env.workspace = ws2
ras_names = arcpy.ListRasters()
for ras_name in ras_names:
name, ext = os.path.splitext(ras_name)
ras = arcpy.Raster(os.path.join(ws2, ras_name))
mean =arcpy.GetRasterProperties_management(ras, "MEAN")
STD=arcpy.GetRasterProperties_management(ras, "STD")
out_ras = ras - (mean + 3 * STD )
out_ras.save(v_name_sc_img.format(name))
Best Answer
GetRasterProperties is returning a Result object, not the actual value of for example mean:
Try using getOutput method. The output will be a string so convert it to float (or int if you want):