This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Create MathOp Square Raster Snippet (ArcObjects .NET 10.4 SDK) |
Create an raster that is the square from an input GeoDataset.
/// <summary> /// Create an raster that is the square from an input GeoDataset. /// </summary> /// <param name="geoDataset">An IGeoDataset interface that has cell values that need to have the square value computed.</param> /// <returns>An IGeoDataset interface that contains square values of the input raster.</returns> /// <remarks> /// Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor. /// /// For information about the IMathOp.Square Method see: /// http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IMathOp_Square.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 CreateMathOpSquareRaster(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) { // Create the RasterMathOps object ESRI.ArcGIS.SpatialAnalyst.IMathOp mathOp=new ESRI.ArcGIS.SpatialAnalyst.RasterMathOpsClass(); // Create the output raster object ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset_output=mathOp.Square(geoDataset); return geoDataset_output; } else { //Invalid type of GeoDataset for this process return null; } }
''' <summary> ''' Create an raster that is the square from an input GeoDataset. ''' </summary> ''' <param name="geoDataset">An IGeoDataset interface that has cell values that need to have the square value computed.</param> ''' <returns>An IGeoDataset interface that contains square values of the input raster.</returns> ''' <remarks> ''' Note: the input geoDataset must be of Type IRaster, IRasterDataset, IRasterBand, or IRasterDescriptor. ''' ''' For information about the IMathOp.Square Method see: ''' http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriSpatialAnalyst/IMathOp_Square.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 CreateMathOpSquareRaster(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 ' Create the RasterMathOps object Dim mathOp As ESRI.ArcGIS.SpatialAnalyst.IMathOp=New ESRI.ArcGIS.SpatialAnalyst.RasterMathOpsClass ' Create the output raster object Dim geoDataset_output As ESRI.ArcGIS.Geodatabase.IGeoDataset=mathOp.Square(geoDataset) Return geoDataset_output Else 'Invalid type of GeoDataset for this process Return Nothing End If End Function