Raster Calculator and VB.NET

2074
3
Jump to solution
09-26-2013 02:43 AM
sameerpuppal
Occasional Contributor
Hi,

how to execute raster calculator from vb.net? there is help or equivalent sample to do that.

following is link :- http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Members/0047000027820000...

ESRI guys please help!

Regards
Sameer
0 Kudos
1 Solution

Accepted Solutions
sameerpuppal
Occasional Contributor
Sameer,

Whilst I agree that the help for this Class is missing basic examples on how to implement the tool and is something that ESRI should rectify, a simple search on this forum for "RasterCalculator" will find you enough code examples to work out how to use it.


Finally did it! posting so that this might be helpful for someone like me. and someone may find it by searching "RasterCalculator" as you suggested...

Public Sub ExecuteRasterCalc()
        Dim expression As String = "'D:\Clip2.img'*'D:\Clip3.img'"
        Dim outputpath As String = "C:\Default.gdb\rastercalc7"
        Dim geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
        Dim ToolRasterCalc As New ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator(expression, outputpath)
        geoprocessor.OverwriteOutput = True
        geoprocessor.AddOutputsToMap = True
        Dim result As IGeoProcessorResult = geoprocessor.Execute(ToolRasterCalc, Nothing)
    End Sub

Regards,
Sameer Puppal

View solution in original post

0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor
Sameer,

Whilst I agree that the help for this Class is missing basic examples on how to implement the tool and is something that ESRI should rectify, a simple search on this forum for "RasterCalculator" will find you enough code examples to work out how to use it.
0 Kudos
sameerpuppal
Occasional Contributor
Sameer,

Whilst I agree that the help for this Class is missing basic examples on how to implement the tool and is something that ESRI should rectify, a simple search on this forum for "RasterCalculator" will find you enough code examples to work out how to use it.



Duncan,

I have done quite research before posting it here. while i don't think you can find 'enough' codes just by searching "RasterCalculator".
I do not want to use RasterMapAlgebraOp and RasterModel is my basic criteria. when i search as you suggested then 99pc of the code are done by using RasterMapAlgebraOp / RasterModel.

let me know if you can help!

Sameer
0 Kudos
sameerpuppal
Occasional Contributor
Sameer,

Whilst I agree that the help for this Class is missing basic examples on how to implement the tool and is something that ESRI should rectify, a simple search on this forum for "RasterCalculator" will find you enough code examples to work out how to use it.


Finally did it! posting so that this might be helpful for someone like me. and someone may find it by searching "RasterCalculator" as you suggested...

Public Sub ExecuteRasterCalc()
        Dim expression As String = "'D:\Clip2.img'*'D:\Clip3.img'"
        Dim outputpath As String = "C:\Default.gdb\rastercalc7"
        Dim geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
        Dim ToolRasterCalc As New ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator(expression, outputpath)
        geoprocessor.OverwriteOutput = True
        geoprocessor.AddOutputsToMap = True
        Dim result As IGeoProcessorResult = geoprocessor.Execute(ToolRasterCalc, Nothing)
    End Sub

Regards,
Sameer Puppal
0 Kudos