I've been trying to learn the raster calculator but have been stuck on this equation for a couple days. I am in an intro to python class but I still do not understand it all that well. Can anyone help??
this is the equation I need to put in and this is what I have in the calculator.
I've been changing things around a lot but nothing seems to work.
if it helps this is the error I keep having
Thanks.
power is normally ** not ^
Unfortunately that did not work, any other suggestions?
well I am not quite sure why you had the %... % in the first case... and in the other dialog you have the grid name within a list ... ie square brackets [ grid name ] perhaps get rid of the brackets as well, it may be failing on the 'list'... and check the raster calculator to see if they do use the ^ operator for power (**). There are so many 'standards' it is hard to keep track of them (I rarely use the raster calculator, opting for python instead)
Alec, brackets denote lists in Python. You need to use parentheses even though your math equation uses brackets. Dan is correct that ** is used for exponentiation in Python, not ^ which is a bitwise not (not what you want to do!).
Dan, I'm pretty sure the "%raster%" syntax is because Alec is using the Spatial Analyst Raster Calculator tool inside Model Builder. The values inside %s are model variables. The double quotes around that are critical, as this delivers something like "ingrid" to the Raster Calculator tool, which then will see the string and interpret as a raster name, and convert this to a raster object with the Raster() function: Raster("ingrid") before it runs using python. You can see the Python expression in the messages when the tool executes above.
Curtis... didn't see modelbuilder mentioned, but I suspect that would account for it.
(I rarely use the raster calculator, opting for python instead)
IMHO Raster Calculator is very powerful inside Model Builder, I think that's the most appropriate environment for it. As I described above it really maps to Python, all the operators are Python. The only differences is strings in the proper context get wrapped with Raster() for you as I described, which is handy in that environment.
My students use Raster Calculator inside Model Builder for a classic weighted layer exercise. They have to do a binary (sieve mapping) model followed by a weighted overlay model. (I am mean and don't let them use the weighted overlay tool so they can see how weighted combinations work.)
I should have clarified... I use numpy instead
Could you test the following expression?
(0.4+1)*((("%FlowAcc%")*(30/22.1))**0.4)*(((Sin(("%Slope%")*(0.01745))/(0.09))**1.3))
or the below one
(0.4+1)*(Float((("%FlowAcc%")*(30/22.1))**0.4))*(((Sin(("%Slope%")*(0.01745))/(0.09))**1.3))