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


Working with helper objects (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > ArcGIS extensions > Spatial Analyst > Working with helper objects (ArcObjects .NET 10.6 SDK)

Working with helper objects


Summary
This topic provides details on working with helper objects for spatial analysis operations.

About working with helper objects

The Spatial Analyst object model is composed of a collection of objects to perform raster analysis. Where most of the objects perform spatial operations, a small group of objects (commonly referred to as helper objects) are used to specify arguments, such as, neighborhood in a focal statistics operation. These objects are available in GeoAnalyst and SpatialAnalyst objects libraries. 
The following table shows all helper objects and methods that require the helper object:
Library 
Helper object
Method
GeoAnalyst
GeoAnalysisSemiVariogram
Variogram
GeoAnalyst
NumberRemap
ReclassByRemap
GeoAnalyst
RasterNeighborhood
BlockStatistics, FocalStatistics, PointDensity, PointStatistics
GeoAnalyst
RasterRadius
Variogram
GeoAnalyst
StringRemap
ReclassByRemap
SpatialAnalyst
PathDistanceHorizontalFactor
PathAllocation, PathBackLink, PathDistance, PathDistanceFull
SpatilaAnalyst
PathDistanceVerticalFactor
PathAllocation, PathBackLink, PathDistance, PathDistanceFull
The following code example shows how to create the NumberRemap helper object:
[C#]
public void UsingNumberRemap()
{
    IRasterDataset inRaster;
    inRaster=OpenRasterDataset("c:\\temp", "degs2");
    //Create the NumberRemap object. 
    INumberRemap numRemap;
    numRemap=new NumberRemapClass();
    numRemap.MapRange(0.0, 15.0, 1);
    numRemap.MapRange(15.0, 55.0, 2);
    numRemap.MapRange(55.0, 300.0, 3);
    numRemap.MapRange(300.0, 1000.0, 4);
    IReclassOp reclassOp;
    reclassOp=new RasterReclassOpClass();
    //Use the NumberRemap object in RasterReclassOp. 
    IRaster rasOut;
    rasOut=(IRaster)reclassOp.ReclassByRemap((IGeoDataset)inRaster, numRemap as
        IRemap, true);
}
[VB.NET]
Public Sub UsingNumberRemap()
    Dim inRaster As IRasterDataset
    inRaster=OpenRasterDataset("c:\temp", "degs2")
    'Create the NumberRemap object.
    Dim numRemap As INumberRemap
    numRemap=New NumberRemapClass()
    numRemap.MapRange(0.0, 15.0, 1)
    numRemap.MapRange(15.0, 55.0, 2)
    numRemap.MapRange(55.0, 300.0, 3)
    numRemap.MapRange(300.0, 1000.0, 4)
    Dim reclassOp As IReclassOp
    reclassOp=New RasterReclassOpClass()
    'Use the NumberRemap object in RasterReclassOp.
    Dim rasOut As IRaster
    rasOut=reclassOp.ReclassByRemap(inRaster, numRemap, True)
End Sub
The following code example shows how to create the RasterRadius helper object:
[C#]
public void UsingRasterRadius()
{
    IFeatureClass fcClass01=default(IFeatureClass);
    fcClass01=OpenFeatureClassFromShapefile("c:\\temp", "ca.shp");
    // Create FeatureClassDescriptor using a value field. 
    IFeatureClassDescriptor fcDescr=default(IFeatureClassDescriptor);
    fcDescr=new FeatureClassDescriptorClass();
    fcDescr.Create(fcClass01, null, "Ozone");
    // Create raster radius using variable distance. 
    IRasterRadius rasRadius=default(IRasterRadius);
    object object_Missing=System.Type.Missing;
    rasRadius=new RasterRadiusClass();
    rasRadius.SetVariable(12, ref object_Missing);
    //RasterInterpolationOp - Method.
    IRaster rasOut=default(IRaster);
    IInterpolationOp interpOp=default(IInterpolationOp);
    interpOp=new RasterInterpolationOpClass();
    rasOut=(IRaster)interpOp.Krige((IGeoDataset)fcDescr,
        esriGeoAnalysisSemiVariogramEnum.esriGeoAnalysisExponentialSemiVariogram,
        rasRadius, false, ref object_Missing);
}
[VB.NET]
Public Sub UsingRasterRadius()
    Dim fcClass01 As IFeatureClass
    fcClass01=OpenFeatureClassFromShapefile("c:\temp", "ca.shp")
    ' Create FeatureClassDescriptor using a value field.
    Dim fcDescr As IFeatureClassDescriptor
    fcDescr=New FeatureClassDescriptorClass()
    fcDescr.Create(fcClass01, Nothing, "Ozone")
    ' Create raster radius using variable distance.
    Dim rasRadius As IRasterRadius
    rasRadius=New RasterRadiusClass()
    rasRadius.SetVariable(12)
    'RasterInterpolationOp - Method.
    Dim rasOut As IRaster
    Dim interpOp As IInterpolationOp
    interpOp=New RasterInterpolationOpClass()
    rasOut=interpOp.Krige(fcDescr, esriGeoAnalysisSemiVariogramEnum.esriGeoAnalysisExponentialSemiVariogram, rasRadius, False)
End Sub
The following code example shows how to create the RasterNeighborhood helper object:
[C#]
public void UsingRasterNeighborhood()
{
    INeighborhoodOp neighborhoodOp;
    neighborhoodOp=new RasterNeighborhoodOpClass();
    //Input raster. 
    IGeoDataset inRas;
    inRas=(IGeoDataset)OpenRasterDataset("c:\\temp", "block1");
    //Create the raster neighborhood object. 
    IRasterNeighborhood rasNeighborhood;
    rasNeighborhood=new RasterNeighborhoodClass();
    rasNeighborhood.SetRectangle(2, 3, esriGeoAnalysisUnitsEnum.esriUnitsCells);
    //Use the neighborhood object in FocalStatistics. 
    IRaster outRas;
    outRas=(IRaster)neighborhoodOp.FocalStatistics(inRas,
        esriGeoAnalysisStatisticsEnum.esriGeoAnalysisStatsMean, rasNeighborhood,
        true);
}
[VB.NET]
Public Sub UsingRasterNeighborhood()
    Dim neighborhoodOp As INeighborhoodOp
    neighborhoodOp=New RasterNeighborhoodOpClass()
    'Input raster.
    Dim inRas As IGeoDataset
    inRas=OpenRasterDataset("c:\temp", "block1")
    'Create the raster neighborhood object.
    Dim rasNeighborhood As IRasterNeighborhood
    rasNeighborhood=New RasterNeighborhoodClass()
    rasNeighborhood.SetRectangle(2, 3, esriGeoAnalysisUnitsEnum.esriUnitsCells)
    'Use the neighborhood object in FocalStatistics.
    Dim outRas As IRaster
    outRas=CType(neighborhoodOp.FocalStatistics(inRas, esriGeoAnalysisStatisticsEnum.esriGeoAnalysisStatsMean, rasNeighborhood, True), IRaster)
End Sub






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic: Spatial Analyst ArcGIS Desktop Basic: Spatial Analyst
ArcGIS Desktop Standard: Spatial Analyst ArcGIS Desktop Standard: Spatial Analyst
ArcGIS Desktop Advanced: Spatial Analyst ArcGIS Desktop Advanced: Spatial Analyst