Create GeneralizeOp Boundary Clean Raster Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Create GeneralizeOp Boundary Clean Raster Snippet

Create a clean (smooth) boundary between zones raster from an input GeoDataset.

[C#]
/// <summary>
/// Create a clean (smooth) boundary between zones raster from an input GeoDataset.
/// </summary>
/// <param name="geoDataset">An IGeoDataset interface that has cell values that need to have a boundary smoothed between zones computed.</param>
/// <returns>An IGeoDataset interface that contains smooth boundary between zones values of the input raster.</returns>
/// <remarks>
/// Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
/// 
/// The IGeneralizeOp.BoundaryClean Method has two options (sortType and runTwice) that 
/// will greatly vary the output raster. These values will need to be adjusted for your application to achieve 
/// the desired results.
/// 
/// For information about the IGeneralizeOp.BoundaryClean Method see:
/// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IGeneralizeOp_BoundaryClean.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 CreateGeneralizeOpBoundaryCleanRaster(ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset)
{

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

        // Create the RasterGeneralizeOp object                 
        ESRI.ArcGIS.SpatialAnalyst.IGeneralizeOp generalizeOp=new ESRI.ArcGIS.SpatialAnalyst.RasterGeneralizeOpClass();

        // Declare the output raster object
        //Note: Adjust the IGeneralizeOp.BoundaryClea method options to suit your applications need.
        ESRI.ArcGIS.Geodatabase.IGeoDataset geodataset_output=generalizeOp.BoundaryClean(geoDataset, ESRI.ArcGIS.SpatialAnalyst.esriGeoAnalysisSortEnum.esriGeoAnalysisSortAscending, true);

        return geodataset_output;

    }
    else
    {

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

    }

}
[Visual Basic .NET]
''' <summary>
''' Create a clean (smooth) boundary between zones raster from an input GeoDataset.
''' </summary>
''' <param name="geoDataset">An IGeoDataset interface that has cell values that need to have a boundary smoothed between zones computed.</param>
''' <returns>An IGeoDataset interface that contains smooth boundary between zones values of the input raster.</returns>
''' <remarks>
''' Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
''' 
''' The IGeneralizeOp.BoundaryClean Method has two options (sortType and runTwice) that 
''' will greatly vary the output raster. These values will need to be adjusted for your application to achieve 
''' the desired results.
''' 
''' For information about the IGeneralizeOp.BoundaryClean Method see:
''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IGeneralizeOp_BoundaryClean.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 CreateGeneralizeOpBoundaryCleanRaster(ByVal geoDataset As ESRI.ArcGIS.Geodatabase.IGeoDataset) As ESRI.ArcGIS.Geodatabase.IGeoDataset

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

    ' Create the RasterGeneralizeOp object                      
    Dim generalizeOp As ESRI.ArcGIS.SpatialAnalyst.IGeneralizeOp=New ESRI.ArcGIS.SpatialAnalyst.RasterGeneralizeOpClass

    ' Declare the output raster object
    'Note: Adjust the IGeneralizeOp.BoundaryClea method options to suit your applications need.
    Dim geodataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=generalizeOp.BoundaryClean(geoDataset, ESRI.ArcGIS.SpatialAnalyst.esriGeoAnalysisSortEnum.esriGeoAnalysisSortAscending, True)

    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