Arc Objects Spatial analyst Con Condition

4164
2
01-04-2015 04:24 AM
NadirHussain
Occasional Contributor II

If inRaster < inputnumber1 Then

   outRaster = 1

ElseIf inRaster > inputnumber2 Then

   outRaster =0

ElseIf inRaster >= inputnumber1 and   inRaster<= inputnumber2 Then

    outRaster = 0.5 * (1 + cos(3.14159*((inRasterinputnumber1 )(inputnumber2 - inputnumber1 ))))

Else

outRaster = 0

The above statments i have to make in arcobjects by using spatial analyst.I am totally confused.Please help.How to make condition in IConditionalop of  spatial analyst.Any help will be appreciated.

Thanks in Advance.

Regards

0 Kudos
2 Replies
XanderBakker
Esri Esteemed Contributor

If you would use this Con statement manually in the Raster Calculator, it would probably look something like:

Con(inRaster < inputnumber1, 1, Con(inRaster > inputnumber2, 0, Con((inRaster >= inputnumber1) AND (inRaster<= inputnumber2), 0.5 * (1 + cos(3.14159 * ((inRaster – inputnumber1) * (inputnumber2 - inputnumber1)))), 0)))

Since you're using ArcObjects, things will get a bit more complicated to nest the Con Statements. Maybe you can find some useful info here:

0 Kudos
ModyBuchbinder
Esri Regular Contributor

Hi

You can just get the pixels with direct read into array and use any calculation.

Check this: How to access pixel data using the RawBlocks object (ArcObjects .NET 10 SDK)

Mody

0 Kudos