AnsweredAssumed Answered

Raster Calculator Function Does not Takes Predefined Variable

Question asked by sourav_164 on Jun 7, 2018
Latest reply on Jun 12, 2018 by sourav_164

I have written a python script that finds the mean of all pixel values in a raster. Once I get the mean (suppose 0.3 in this case), I can use raster calculator and assign pixel value of 1 to each pixel higher than the mean and 0 to everything else. The equation is as follows -


Float(Con("Raster1"<0.3, 0, 1))


However, there are 30 raster files, thus, I want to avoid manually using the Raster Calculator. I have added the following codes to the script- 


Raster_mean = got from previous script [0.3 in this case]'Float(Con("Raster1"<Raster_mean, 0, 1))' ,  "E:/ArcGIS Python/raster10")


I am getting the following errors-

NameError: name 'Raster_mean' is not defined.  Failed to execute (RasterCalculator). 


Seems like it does not take any predefined variable but only raw values. Is there any other option to conduct the task?