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


Create LogicalOp Combinatorial OR Raster Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Create LogicalOp Combinatorial OR Raster Snippet

Create a logical combinatorial 'OR' raster from two input GeoDataset's.

[C#]
/// <summary>
/// Create a logical combinatorial 'OR' raster from two input GeoDataset's.
/// </summary>
/// <param name="geoDataset_1">An IGeoDataset interface that has cell values that need to have a combinatorial 'OR' computed.</param>
/// <param name="geoDataset_2">An IGeoDataset interface that has cell values that need to have a combinatorial 'OR' computed.</param>
/// <returns>An IGeoDataset interface that is the result of a combinatorial 'OR' from two input rasters.</returns>
/// <remarks>
/// Note: the input geoDataset's must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
/// They must be a positive integer rasters.
/// 
/// For information about the ILogicalOp.CombinatorialOr Method see:
/// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/ILogicalOp_CombinatorialOr.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 CreateLogicalOpCombinatorialORRaster(ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_1, ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_2)
{

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

        // Create the MathOps object                            
        ESRI.ArcGIS.SpatialAnalyst.ILogicalOp logicalOp=new ESRI.ArcGIS.SpatialAnalyst.RasterMathOpsClass();

        // Declare the output raster object                     
        ESRI.ArcGIS.Geodatabase.IGeoDataset geodataset_output=logicalOp.CombinatorialOr(geoDataset_1, geoDataset_2);

        return geodataset_output;

    }
    else
    {

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

    }

}
[Visual Basic .NET]
''' <summary>
''' Create a logical combinatorial 'OR' raster from two input GeoDataset's.
''' </summary>
''' <param name="geoDataset_1">An IGeoDataset interface that has cell values that need to have a combinatorial 'OR' computed.</param>
''' <param name="geoDataset_2">An IGeoDataset interface that has cell values that need to have a combinatorial 'OR' computed.</param>
''' <returns>An IGeoDataset interface that is the result of a combinatorial 'OR' from two input rasters.</returns>
''' <remarks>
''' Note: the input geoDataset's must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
''' They must be a positive integer rasters.
''' 
''' For information about the ILogicalOp.CombinatorialOr Method see:
''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/ILogicalOp_CombinatorialOr.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 CreateLogicalOpCombinatorialORRaster(ByVal geoDataset_1 As ESRI.ArcGIS.Geodatabase.IGeoDataset, ByVal geoDataset_2 As ESRI.ArcGIS.Geodatabase.IGeoDataset) As ESRI.ArcGIS.Geodatabase.IGeoDataset

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

    ' Create the MathOps object                         
    Dim logicalOp As ESRI.ArcGIS.SpatialAnalyst.ILogicalOp=New ESRI.ArcGIS.SpatialAnalyst.RasterMathOpsClass

    ' Declare the output raster object                  
    Dim geodataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=logicalOp.CombinatorialOr(geoDataset_1, geoDataset_2)

    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.GeoDatabaseDistributed
  • ESRI.ArcGIS.SpatialAnalyst
  • ESRI.ArcGIS.System