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


Create DistanceOp Cost Back Link Raster Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Create DistanceOp Cost Back Link Raster Snippet

Create a raster that is the neighbor that is the next cell on the least-accumulative-cost path from two input GeoDataset's.

[C#]
/// <summary>
/// Create a raster that is the neighbor that is the next cell on the least-accumulative-cost path from two input GeoDataset's.
/// </summary>
/// <param name="geoDataset_1">An IGeoDataset interface that identifies those cells or locations to which the least accumulated cost distances for every cell is calculated.</param>
/// <param name="geoDataset_2">An IGeoDataset interface that definines the impedance or cost to move planimetrically through each cell.</param>
/// <returns>An IGeoDataset interface that is the neighbor that is the next cell on the least-accumulative-cost path.</returns>
/// <remarks>
/// Note: 
/// The input geoDataset_1 must be of Type IRaster, IRasterDataset, IRasterBand, IRasterDescriptor, or FeatureClass. For Rasters, the 
/// input value types can be either integer, string or floating-point type if in_raster_value is used.
/// 
/// The input geoDataset_2 must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor. The values on the geoDataset_2 
/// can be integer or floating point, but they cannot be negative (you cannot have a negative cost).
/// 
/// The IDistanceOp.CostBackLink Method has two options (maxDistance and valueRaster) 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 IDistanceOp.CostBackLink Method see:
/// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IDistanceOp_CostBackLink.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 CreateDistanceOpCostBackLinkRaster(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_1 is ESRI.ArcGIS.Geodatabase.IFeatureClass) & (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 RasterDistanceOp object                   
        ESRI.ArcGIS.SpatialAnalyst.IDistanceOp distanceOp=new ESRI.ArcGIS.SpatialAnalyst.RasterDistanceOpClass();

        // Declare the output raster object
        //Note: Adjust the IDistanceOp.CostBackLink method options to suit your applications need.
        object object_missing1=System.Type.Missing;
        object object_missing2=System.Type.Missing;
        ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_output=distanceOp.CostBackLink(geoDataset_1, geoDataset_2, ref object_missing1, ref object_missing2);

        return geoDataset_output;
    }
    else
    {

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

    }

}
[Visual Basic .NET]
''' <summary>
''' Create a raster that is the neighbor that is the next cell on the least-accumulative-cost path from two input GeoDataset's.
''' </summary>
''' <param name="geoDataset_1">An IGeoDataset interface that identifies those cells or locations to which the least accumulated cost distances for every cell is calculated.</param>
''' <param name="geoDataset_2">An IGeoDataset interface that definines the impedance or cost to move planimetrically through each cell.</param>
''' <returns>An IGeoDataset interface that is the neighbor that is the next cell on the least-accumulative-cost path.</returns>
''' <remarks>
''' Note: 
''' The input geoDataset_1 must be of Type IRaster, IRasterDataset, IRasterBand, IRasterDescriptor, or FeatureClass. For Rasters, the 
''' input value types can be either integer, string or floating-point type if in_raster_value is used.
''' 
''' The input geoDataset_2 must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor. The values on the geoDataset_2 
''' can be integer or floating point, but they cannot be negative (you cannot have a negative cost).
''' 
''' The IDistanceOp.CostBackLink Method has two options (maxDistance and valueRaster) 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 IDistanceOp.CostBackLink Method see:
''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IDistanceOp_CostBackLink.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 CreateDistanceOpCostBackLinkRaster(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 _
  Or TypeOf geoDataset_1 Is ESRI.ArcGIS.Geodatabase.IFeatureClass) _
  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 RasterDistanceOp object                        
    Dim distanceOp As ESRI.ArcGIS.SpatialAnalyst.IDistanceOp=New ESRI.ArcGIS.SpatialAnalyst.RasterDistanceOpClass

    ' Declare the output raster object
    'Note: Adjust the IDistanceOp.CostBackLink method options to suit your applications need.
    Dim object_missing1 As System.Object=System.Type.Missing
    Dim object_missing2 As System.Object=System.Type.Missing
    Dim geoDataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=distanceOp.CostBackLink(geoDataset_1, geoDataset_2, object_missing1, object_missing2)

    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
  • System