Hallo,
i know its allmost the same question as "Use Raster Calculator to Modify DEM Elevations based on Vector Layerbut i am trying to build a model but i am stuck.
my first model, and i got that to work has this expression:
Con(IsNull("%Output_raster%"),float(%Double%), "%Output_raster%"). but this sets a value.
what I now want is to subtract a value from the DEM using this model.
can sameone help me with the right expressing.
Thank you and Greeting Peter
Solved! Go to Solution.
Do you need to decide whether to subtract or set the value based on the pixel position (different parts of the raster would be subtracted or set), or do you want to decide for the whole model (on one run you subtract all that meet a condition, and on the next you set all that meet a condition)?
edit: it sounds like you want to apply your choice whether to subtract or set for the whole model. You can do this by adding a new variable (boolean or integer or some other flag) and nesting Con() statements:
Con(newVariable = 1, Con(IsNull("%Mask_raster%"),"%Input_raster%", ("%Input_raster%" -float(%Double%))), Con(IsNull("%Mask_raster%"),"%Input_raster%", ("%Input_raster%" == float(%Double%))))
...which translates to: if the value of newVariable = 1, do the subtract statement, else do the set statement. You could do this with a boolean checkbox, too.
Con is confusing, but hopefully this will help.
Con(first, second, third) translates to: for each pixel, if the first thing is true, return the second thing. If the first thing is not true, return the third thing.
I'm not sure I completely understand what you want to do, but if I'm right that you want to subtract a value (or raster) if it falls within a mask, and use the original value if not, then you should use an expression like:
Con(IsNull("mask"), "original", ("original" - some number or raster))
This expression translates to: check each pixel. If it is not in the mask (i.e. is null), use the original raster value. If the pixel is in the mask, subtract some value (or raster) from the original raster. Of course, change "some value or raster", to a value or raster.
Thank you Darren for this clear explanation. Now I get it
This model is for burning my water into a DEM.
This is my new model
The expression i use now is:
Con(IsNull("%Mask_raster%"),"%Input_raster%", ("%Input_raster%" -float(%Double%)))
And it works great. BUT I can only use it to subtract a value. I could think about a use for this model when I want to simply set a value. The expression would look like:
Con(IsNull("%Mask_raster%"),"%Input_raster%", ("%Input_raster%" == float(%Double%)))
Is there a way to choose between – (subtract) and == (set value) in a model?
again thank you Darren
Just return the double thus :
Con(IsNull("%Mask_raster%"),"%Input_raster%", (float(%Double%)))
sorry you did not understand me. your expression only sets a value. now i cannot subtract a value from my DEM with this expression.
i could make 2 models but is there a way to do both in 1 model?
gr Peter
Do you need to decide whether to subtract or set the value based on the pixel position (different parts of the raster would be subtracted or set), or do you want to decide for the whole model (on one run you subtract all that meet a condition, and on the next you set all that meet a condition)?
edit: it sounds like you want to apply your choice whether to subtract or set for the whole model. You can do this by adding a new variable (boolean or integer or some other flag) and nesting Con() statements:
Con(newVariable = 1, Con(IsNull("%Mask_raster%"),"%Input_raster%", ("%Input_raster%" -float(%Double%))), Con(IsNull("%Mask_raster%"),"%Input_raster%", ("%Input_raster%" == float(%Double%))))
...which translates to: if the value of newVariable = 1, do the subtract statement, else do the set statement. You could do this with a boolean checkbox, too.
He Darren,
your right this is what i want with this model. i understand the expression but setting the new variable is not working.
i would like to use the boolean chack box. it is in my model as a precondition for the raster calculator. this do's not work. i did not change your expression. i think i need to set the boolean but do not know were or how.
thank you again for the help and the explanation. that the tools is not working is all on me
greetings Peter
Darren, don't forget double equals: ==
Also if you have a boolean model variable named CheckBox you can recast it to integer.
Con( int("%CheckBox%") == 1, Con(IsNull("Mask_raster") "Input_raster", ("Input_raster" - float(%Double%))), Con(IsNull("Mask_raster"), "Input_raster", float(%Double%)))