Con condition Expression arcobjects error

3933
2
01-13-2015 10:36 PM
NadirHussain
Occasional Contributor II

Dear All.

Below is the code for con opertor in arcmap.

When i execute it gives me the error.Pls suggest and show to me where is something wrong.

rasModel = New RasterModelClass

rasModel.BindRaster(slopeRDN, "slope")

strExpression = "Con" + "(" + """" + "[slope]" + """" + ">" + "0" + "," + """" + "[slope]" + """" + "," + "0.000001" + ")"

  rasModel.Script = strExpression---error throw on this line

Error:010084 invalid command or expression.

thanks in advance

0 Kudos
2 Replies
NadirHussain
Occasional Contributor II

Dear All.

Below is the code for con in map aljebra.

When i execute it gives me the error.Pls suggest and show to me where is something wrong.

rasModel = New RasterModelClass

rasModel.BindRaster(slopeRDN, "slope")

strExpression = "Con" + "(" + """" + "[slope]" + """" + ">" + "0" + "," + """" + "[slope]" + """" + "," + "0.000001" + ")"

  rasModel.Script = strExpression

rasModel.execute()

Error:010084 invalid command or expression.

thanks in advance

0 Kudos
XanderBakker
Esri Esteemed Contributor

Why don't you just you the expression below? There is no need to divide the expression into small parts and then concatenate it. The raster [slope] should not be in between quotes.

Con([slope] > 0, [slope], 0.000001)

0 Kudos