This document is archived and information here might be outdated.  Recommended version.


Create TrigOp ATan2 Raster Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Create TrigOp ATan2 Raster Snippet

Create an inverse tangent raster from two input GeoDataset's.

[C#]
/// <summary>
/// Create an inverse tangent raster from two input GeoDataset's.
/// </summary>
/// <param name="geoDataset_x">An IGeoDataset interface that has cell values that are the numerator (x).</param>
/// <param name="geoDataset_y">An IGeoDatasett interface that has cell values that are the denominator (y).</param>
/// <returns>An IGeoDataset interface that is the result of an inverse tanget from two input rasters (x/y).</returns>
/// <remarks>
/// Note: the input geoDataset's must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
/// 
/// For information about the ITrigOp.ATan2 Method see:
/// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/ITrigOp_ATan2.htm
/// 
/// For more information on working with the ArcGIS Spatial Anaylst objects see:
/// http://edndoc.esri.com/arcobjects/9.2/CPP_VB6_VBA_VCPP_Doc/COM/VB6/working/work_rasters/sptl_analyst_objs.htm
/// </remarks>
public ESRI.ArcGIS.Geodatabase.IGeoDataset CreateTrigOpATan2Raster(ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_x, ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_y)
{

    if ((geoDataset_x is ESRI.ArcGIS.Geodatabase.IRaster | geoDataset_x is ESRI.ArcGIS.Geodatabase.IRasterDataset | geoDataset_x is ESRI.ArcGIS.DataSourcesRaster.IRasterBand | geoDataset_x is ESRI.ArcGIS.GeoAnalyst.IRasterDescriptor) & (geoDataset_y is ESRI.ArcGIS.Geodatabase.IRaster | geoDataset_y is ESRI.ArcGIS.Geodatabase.IRasterDataset | geoDataset_y is ESRI.ArcGIS.DataSourcesRaster.IRasterBand | geoDataset_y is ESRI.ArcGIS.GeoAnalyst.IRasterDescriptor))
    {

        // Create the MathOps object                            
        ESRI.ArcGIS.SpatialAnalyst.ITrigOp trigOp=new ESRI.ArcGIS.SpatialAnalyst.RasterMathOpsClass();

        // Declare the output raster object                     
        ESRI.ArcGIS.Geodatabase.IGeoDataset geodataset_output=trigOp.ATan2(geoDataset_x, geoDataset_y);

        return geodataset_output;

    }
    else
    {

        //Invalid type of GeoDataset for this process
        return null;

    }

}
[Visual Basic .NET]
''' <summary>
''' Create an inverse tangent raster from two input GeoDataset's.
''' </summary>
''' <param name="geoDataset_x">An IGeoDataset interface that has cell values that are the numerator (x).</param>
''' <param name="geoDataset_y">An IGeoDatasett interface that has cell values that are the denominator (y).</param>
''' <returns>An IGeoDataset interface that is the result of an inverse tanget from two input rasters (x/y).</returns>
''' <remarks>
''' Note: the input geoDataset's must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
''' 
''' For information about the ITrigOp.ATan2 Method see:
''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/ITrigOp_ATan2.htm
''' 
''' For more information on working with the ArcGIS Spatial Anaylst objects see:
''' http://edndoc.esri.com/arcobjects/9.2/CPP_VB6_VBA_VCPP_Doc/COM/VB6/working/work_rasters/sptl_analyst_objs.htm
''' </remarks>
Public Function CreateTrigOpATan2Raster(ByVal geoDataset_x As ESRI.ArcGIS.Geodatabase.IGeoDataset, ByVal geoDataset_y As ESRI.ArcGIS.Geodatabase.IGeoDataset) As ESRI.ArcGIS.Geodatabase.IGeoDataset

  If (TypeOf geoDataset_x Is ESRI.ArcGIS.Geodatabase.IRaster _
  Or TypeOf geoDataset_x Is ESRI.ArcGIS.Geodatabase.IRasterDataset _
  Or TypeOf geoDataset_x Is ESRI.ArcGIS.DataSourcesRaster.IRasterBand _
  Or TypeOf geoDataset_x Is ESRI.ArcGIS.GeoAnalyst.IRasterDescriptor) _
  And (TypeOf geoDataset_y Is ESRI.ArcGIS.Geodatabase.IRaster _
  Or TypeOf geoDataset_y Is ESRI.ArcGIS.Geodatabase.IRasterDataset _
  Or TypeOf geoDataset_y Is ESRI.ArcGIS.DataSourcesRaster.IRasterBand _
  Or TypeOf geoDataset_y Is ESRI.ArcGIS.GeoAnalyst.IRasterDescriptor) Then

    ' Create the MathOps object                         
    Dim trigOp As ESRI.ArcGIS.SpatialAnalyst.ITrigOp=New ESRI.ArcGIS.SpatialAnalyst.RasterMathOpsClass

    ' Declare the output raster object                  
    Dim geodataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=trigOp.ATan2(geoDataset_x, geoDataset_y)

    Return geodataset_output

  Else

    'Invalid type of GeoDataset for this process
    Return Nothing

  End If

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.DataSourcesRaster
  • ESRI.ArcGIS.GeoAnalyst
  • ESRI.ArcGIS.Geodatabase
  • ESRI.ArcGIS.SpatialAnalyst
  • ESRI.ArcGIS.System