Create a raster that has Euclidean allocation to the closest source.
[C#]
/// <summary> /// Create a raster that has Euclidean allocation to the closest source. /// </summary> /// <param name="geoDataset">An IGeoDataset interface that identifies those cells or locations whose values are assigned to the output cell locations that they are closest to.</param> /// <returns>An IGeoDataset interface that has Euclidean allocation to the closest source.</returns> /// <remarks> /// Note: the input geoDataset's must be of Type IRaster, IRasterDataset, IRasterBand, IRasterDescriptor or IFeatureClass. /// /// The IDistanceOp.EucDistanceFull Method has two options (maxDistance and valueRaster) that /// will greatly vary the output raster. Thess values will need to be adjusted for your application to achieve /// the desired results. /// /// For information about the IDistanceOp.EucDistanceFull Method see: /// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IDistanceOp_EucDistanceFull.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 CreateDistanceOpEucDistanceFullAllocationRaster(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 | geoDataset is ESRI.ArcGIS.Geodatabase.IFeatureClass) { // Create the RasterDistanceOp object ESRI.ArcGIS.SpatialAnalyst.IDistanceOp distanceOp = new ESRI.ArcGIS.SpatialAnalyst.RasterDistanceOpClass(); // Declare the output raster object //Note: Adjust the IDistanceOp.EucDistanceFull method options to suit your applications need. object object_missing1 = System.Type.Missing; object object_missing2 = System.Type.Missing; ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_result = distanceOp.EucDistanceFull(geoDataset, false, false, true, ref object_missing1, ref object_missing2); // Access the Euclidean allocation raster from the output generated ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection rasterBandCollection = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)geoDataset_result; // Explicit Cast ESRI.ArcGIS.DataSourcesRaster.IRasterBand rasterBand = rasterBandCollection.Item(1); ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_output = (ESRI.ArcGIS.Geodatabase.IGeoDataset)rasterBand; // Explicit Cast return geoDataset_output; } else { //Invalid type of GeoDataset for this process return null; } }
[Visual Basic .NET]
''' <summary> ''' Create a raster that has Euclidean allocation to the closest source. ''' </summary> ''' <param name="geoDataset">An IGeoDataset interface that identifies those cells or locations whose values are assigned to the output cell locations that they are closest to.</param> ''' <returns>An IGeoDataset interface that has Euclidean allocation to the closest source.</returns> ''' <remarks> ''' Note: the input geoDataset's must be of Type IRaster, IRasterDataset, IRasterBand, IRasterDescriptor or IFeatureClass. ''' ''' The IDistanceOp.EucDistanceFull Method has two options (maxDistance and valueRaster) that ''' will greatly vary the output raster. Thess values will need to be adjusted for your application to achieve ''' the desired results. ''' ''' For information about the IDistanceOp.EucDistanceFull Method see: ''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IDistanceOp_EucDistanceFull.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 CreateDistanceOpEucDistanceFullAllocationRaster(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 _ Or TypeOf geoDataset Is ESRI.ArcGIS.Geodatabase.IFeatureClass) 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.EucDistanceFull 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_result As ESRI.ArcGIS.Geodatabase.IGeoDataset = distanceOp.EucDistanceFull(geoDataset, False, False, True, object_missing1, object_missing2) ' Access the Euclidean allocation raster from the output generated Dim rasterBandCollection As ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection = CType(geoDataset_result, ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection) ' Explicit Cast Dim rasterBand As ESRI.ArcGIS.DataSourcesRaster.IRasterBand = rasterBandCollection.Item(1) Dim geoDataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset = CType(rasterBand, ESRI.ArcGIS.Geodatabase.IGeoDataset) ' Explicit Cast Return geoDataset_output Else 'Invalid type of GeoDataset for this process Return Nothing End If End Function