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


Create ExtractOp Circle Raster Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Create ExtractOp Circle Raster Snippet

Create a raster from an input GeoDataset that will have it's values cut out from a Circle.

[C#]
/// <summary>
/// Create a raster from an input GeoDataset that will have it's values cut out from a Circle.
/// </summary>
/// <param name="geoDataset">An IGeoDataset interface that has cell values that will be cut out by a circle.</param>
/// <param name="circularArc">An ICircularArc interface that define the circle to cut through the input GeoDataset.</param>
/// <returns>An IGeoDataset interface that contains values from the input GeoDataset that were cut out by a cirlce.</returns>
/// <remarks>
/// Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
/// 
/// For the CircularArc, the coordinates are specified in map units and are in the same units as the GeoDataset.
/// 
/// The IExtractionOp.Circle Method has an option (selectInside) that will greatly vary the output raster. 
/// This value will need to be adjusted for your application to achieve the desired results.
/// 
/// For information about the IExtractionOp.Circle Method see:
/// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IExtractionOp_Circle.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 CreateExtractOpCircleRaster(ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset, ESRI.ArcGIS.Geometry.ICircularArc circularArc)
{

    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 RasterExtractionOp object
        ESRI.ArcGIS.SpatialAnalyst.IExtractionOp extractionOp=new ESRI.ArcGIS.SpatialAnalyst.RasterExtractionOpClass();

        //Call the method
        //Note: Adjust the IExtractionOp.Circle method options to suit your applications need.
        ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_output=extractionOp.Circle(geoDataset, circularArc, true);

        return geoDataset_output;

    }
    else
    {

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

    }

}
[Visual Basic .NET]
''' <summary>
''' Create a raster from an input GeoDataset that will have it's values cut out from a Circle.
''' </summary>
''' <param name="geoDataset">An IGeoDataset interface that has cell values that will be cut out by a circle.</param>
''' <param name="circularArc">An ICircularArc interface that define the circle to cut through the input GeoDataset.</param>
''' <returns>An IGeoDataset interface that contains values from the input GeoDataset that were cut out by a cirlce.</returns>
''' <remarks>
''' Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor.
''' 
''' For the CircularArc, the coordinates are specified in map units and are in the same units as the GeoDataset.
''' 
''' The IExtractionOp.Circle Method has an option (selectInside) that will greatly vary the output raster. 
''' This value will need to be adjusted for your application to achieve the desired results.
''' 
''' For information about the IExtractionOp.Circle Method see:
''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IExtractionOp_Circle.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 CreateExtractOpCircleRaster(ByVal geoDataset As ESRI.ArcGIS.Geodatabase.IGeoDataset, ByVal circularArc As ESRI.ArcGIS.Geometry.ICircularArc) 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 RasterExtractionOp object
    Dim extractionOp As ESRI.ArcGIS.SpatialAnalyst.IExtractionOp=New ESRI.ArcGIS.SpatialAnalyst.RasterExtractionOpClass

    'Call the method
    'Note: Adjust the IExtractionOp.Circle method options to suit your applications need.
    Dim geoDataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=extractionOp.Circle(geoDataset, circularArc, 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