Sorry, but I'm a little bit confused, this is most likely due to my naivety in reading Python syntax.
When looking at lines 05-07. of code, I see
- con_rasters = []
- for raster in rasters:
- con_rasters.append(Con(IsNull(raster),0,raster))
I feel that it is only running the first half of the expression, which is...
Float(Con(IsNull("w1") ,0,"w1") + Con(IsNull("w2"), 0,"w2")+Con(IsNull("w3"), 0,"w3")+Con(IsNull("w4"), 0,"w4")
and leaving out the second half of the expression which is....
/ (Con(IsNull("w1"), 0,1) + Con(IsNull("w2"), 0,1)+Con(IsNull("w3"), 0,1)+Con(IsNull("w4"), 0,1))
The expression is essentially the number of times a cell had a value and divide by the number of times it was possible for a value to be detected. The numerator in this case is how many times the pixel had the value 1. The denominator is now many times the pixel did not have No Data (i.e. it had the value 1 or 0).
Expression: number of times a cell had a value / number of times the cell could have had a value Float(Con(IsNull(A),0,A) + Con(IsNull(B),0,B) + Con(IsNull(C),0,C)) / (~IsNull(A) + ~IsNull(B) + ~IsNull(C)) |
I hope that clarifies what I'm trying to achieve and apologies if I've misunderstood your code!