Run the Spatial Analyst Slope tool through the geoprocessor object.
[C#]
///<summary>Run the Spatial Analyst Slope tool through the geoprocessor object.</summary>
///
///<param name="inRaster">A System.String that is the path and filename to the input raster dataset. Example: "D:\SAdata\degs"</param>
///<param name="outRaster">A System.String that is the path and filename to the input raster dataset. Example: "D:\SAdata\slope_out3"</param>
///
///<returns>An IGeoProcessorResult interface.</returns>
///
///<remarks>Make sure to have a Spatial Analyst extension license checked out before calling RunSlopeTool.</remarks>
public ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult CreateSlope(System.String inRaster, System.String outRaster)
{
if(inRaster == "" || outRaster == "")
{
return null;
}
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
gp.OverwriteOutput = true;
ESRI.ArcGIS.SpatialAnalystTools.Slope slopeTool = new ESRI.ArcGIS.SpatialAnalystTools.Slope();
slopeTool.in_raster = inRaster;
slopeTool.out_raster = outRaster;
ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult geoProcessorResult = gp.Execute(slopeTool, null) as ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult;
return geoProcessorResult;
}
[Visual Basic .NET]
'''<summary>Run the Spatial Analyst Slope tool through the geoprocessor object.</summary>
'''
'''<param name="inRaster">A System.String that is the path and filename to the input raster dataset. Example: "D:\SAdata\degs"</param>
'''<param name="outRaster">A System.String that is the path and filename to the input raster dataset. Example: "D:\SAdata\slope_out3"</param>
'''
'''<returns>An IGeoProcessorResult interface.</returns>
'''
'''<remarks>Make sure to have a Spatial Analyst extension license checked out before calling RunSlopeTool.</remarks>
Public Function CreateSlope(ByVal inRaster As System.String, ByVal outRaster As System.String) As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult
If inRaster = "" OrElse outRaster = "" Then
Return Nothing
End If
Dim gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor
gp.OverwriteOutput = True
Dim slopeTool As ESRI.ArcGIS.SpatialAnalystTools.Slope = New ESRI.ArcGIS.SpatialAnalystTools.Slope
slopeTool.in_raster = inRaster
slopeTool.out_raster = outRaster
Dim geoProcessorResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult = TryCast(gp.Execute(slopeTool, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)
Return geoProcessorResult
End Function