This document is archived and information here might be outdated. Recommended version. |
Create a block statistics raster from an input GeoDataset.
/// <summary> /// Create a neighborhood block statistics raster from an input GeoDataset. /// </summary> /// <param name="geodataset">An IGeoDataset interface that has cell values that need to have a neighborhood statistics computed.</param> /// <returns>An IGeoDataset interface that contains statistics for a non-overlapping neighborhood values of the input raster.</returns> /// <remarks> /// Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor. /// /// The INeighborhoodOp.BlockStatistics Method has several options (type, nbrhood, and ignoreNoData) 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 INeighborhoodOp.BlockStatistics Method see: /// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/INeighborhoodOp_BlockStatistics.htm /// /// The IRasterNeighborhood.SetRectangle Method has several options (width, height, and unitsType) 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 IRasterNeighborhood.SetRectangle Method see: /// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoAnalyst/IRasterNeighborhood_SetRectangle.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 CreateNeighborhoodOpBlockStatisticsRaster(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) { // Define the NeighborhoodOp object ESRI.ArcGIS.SpatialAnalyst.INeighborhoodOp neighborhoodOP=new ESRI.ArcGIS.SpatialAnalyst.RasterNeighborhoodOpClass(); // Define and set the neighborhood ESRI.ArcGIS.GeoAnalyst.IRasterNeighborhood rasterNeighborhood=new ESRI.ArcGIS.GeoAnalyst.RasterNeighborhoodClass(); //Note: Adjust the IRasterNeighborhood.SetRectangle method options to suit your applications need. rasterNeighborhood.SetRectangle(3, 3, ESRI.ArcGIS.GeoAnalyst.esriGeoAnalysisUnitsEnum.esriUnitsCells); // Declare the output raster object //Note: Adjust the INeighborhoodOp.BlockStatistics method options to suit your applications need. ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_output=neighborhoodOP.BlockStatistics(geoDataset, ESRI.ArcGIS.GeoAnalyst.esriGeoAnalysisStatisticsEnum.esriGeoAnalysisStatsMean, rasterNeighborhood, true); return geoDataset_output; } else { //Invalid type of GeoDataset for this process return null; } }
''' <summary> ''' Create a neighborhood block statistics raster from an input GeoDataset. ''' </summary> ''' <param name="geodataset">An IGeoDataset interface that has cell values that need to have a neighborhood statistics computed.</param> ''' <returns>An IGeoDataset interface that contains statistics for a non-overlapping neighborhood values of the input raster.</returns> ''' <remarks> ''' Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor. ''' ''' The INeighborhoodOp.BlockStatistics Method has several options (type, nbrhood, and ignoreNoData) 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 INeighborhoodOp.BlockStatistics Method see: ''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/INeighborhoodOp_BlockStatistics.htm ''' ''' The IRasterNeighborhood.SetRectangle Method has several options (width, height, and unitsType) 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 IRasterNeighborhood.SetRectangle Method see: ''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoAnalyst/IRasterNeighborhood_SetRectangle.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 CreateNeighborhoodOpBlockStatisticsRaster(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 ' Define the NeighborhoodOp object Dim neighborhoodOP As ESRI.ArcGIS.SpatialAnalyst.INeighborhoodOp=New ESRI.ArcGIS.SpatialAnalyst.RasterNeighborhoodOpClass ' Define and set the neighborhood Dim rasterNeighborhood As ESRI.ArcGIS.GeoAnalyst.IRasterNeighborhood=New ESRI.ArcGIS.GeoAnalyst.RasterNeighborhoodClass 'Note: Adjust the IRasterNeighborhood.SetRectangle method options to suit your applications need. rasterNeighborhood.SetRectangle(3, 3, ESRI.ArcGIS.GeoAnalyst.esriGeoAnalysisUnitsEnum.esriUnitsCells) ' Declare the output raster object 'Note: Adjust the INeighborhoodOp.BlockStatistics method options to suit your applications need. Dim geoDataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=neighborhoodOP.BlockStatistics(geoDataset, ESRI.ArcGIS.GeoAnalyst.esriGeoAnalysisStatisticsEnum.esriGeoAnalysisStatsMean, rasterNeighborhood, True) Return geoDataset_output Else 'Invalid type of GeoDataset for this process Return Nothing End If End Function