Hello all,
I have a problem with map algebra in raster calculator. I need to create a raster by employing this formula
1/(1+Exp^(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN"))
It is a logistic regression prediction probability formula. The rasters involved are:
Z BIN - a grid raster with binary values (pix type integer)
SALINITET BIN - a grid raster with binary values
Vs_aspect BIN - a grid raster with binary values
Distance to Water - a grid raster with numeric values 0-1000 (distance to water from 0 to 1000 meters) (pix type floating point)
DRENAZA BIN - a grid raster with binary values
Poljski_Vodni_Kapacitet BIN - a grid raster with binary values
When I input the formula in raster calculator as listed above, I get the following error message:
Executing: RasterCalculator 1/(1+Exp^(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN")) "C:\Users\***\Documents\Vrsac\PREDIKCIJA\VPred"
Start Time: Thu Mar 26 19:55:44 2015
1/(1+Exp^(3.642-1.502*Raster(r"Z BIN")-0.784*Raster(r"SALINITET BIN")-0.619*Raster(r"Vs_aspect BIN")-0.004*Raster(r"Distance to Water")-0.738*Raster(r"DRENAZA BIN")-1.029*Raster(r"Poljski_Vodni_Kapacitet BIN")))
ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 5, in rcexec
TypeError: unsupported operand type(s) for +: 'int' and 'function'
Failed to execute (RasterCalculator).
Failed at Thu Mar 26 19:55:44 2015 (Elapsed Time: 0.01 seconds)4
I have no idea what does the error line tell me.
Help please?
Solved! Go to Solution.
Exponent (power) map algebra operator is ** not ^. Here's the list (see Power).
Furthermore, Exp(grid) is a function, so there is no need for ^ or **.
1/(1+Exp(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN"))
or possibly (but untested):
1/(1+math.e**(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN"))
Try keeping the whole expression of "Exp" within a bracket
like
1/(1+(Exp^(3.642...
Just tried it and I get the following error message.
Executing: RasterCalculator 1/(1+(Exp^(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN"))) "C:\Users\***\Documents\Vrsac\PREDIKCIJA\VP"
Start Time: Thu Mar 26 20:27:41 2015
1/(1+(Exp^(3.642-1.502*Raster(r"Z BIN")-0.784*Raster(r"SALINITET BIN")-0.619*Raster(r"Vs_aspect BIN")-0.004*"Distance to Water"-0.738*Raster(r"DRENAZA BIN")-1.029*Raster(r"Poljski_Vodni_Kapacitet BIN"))))
ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 5, in rcexec
TypeError: can't multiply sequence by non-int of type 'float'
Failed to execute (RasterCalculator).
Failed at Thu Mar 26 20:27:41 2015 (Elapsed Time: 0.34 seconds)
I am guessing it is the float type raster that is the problem.
Keep all the constants in bracket.
And the whole expression in Float()
I find that liberal use of brackets and spaces helps with the Raster Calculator...
Exponent (power) map algebra operator is ** not ^. Here's the list (see Power).
Furthermore, Exp(grid) is a function, so there is no need for ^ or **.
1/(1+Exp(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN"))
or possibly (but untested):
1/(1+math.e**(3.642-1.502*"Z BIN"-0.784*"SALINITET BIN"-0.619*"Vs_aspect BIN"-0.004*"Distance to Water"-0.738*"DRENAZA BIN"-1.029*"Poljski_Vodni_Kapacitet BIN"))
Thank you for the input Darren, this proved to be the right answer. It calculated the raster using either of the two formulas you listed, and they are identical.
Again, many thanks.