HOW TO
This VBA code sample demonstrates how to use the IDW method on IInterpolationOp.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Code: ''Get the first layer in the ActiveView (point) Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pMap As IMap Set pMap = pMxDoc.ActiveView Dim pFLayer As IFeatureLayer Set pFLayer = pMap.Layer(0) Dim pFClass As IFeatureClass Set pFClass = pFLayer.FeatureClass Dim pAV As IActiveView Set pAV = pMap Dim pREnv As IEnvelope Set pREnv = pAV.Extent ''************ ' Create FeatureClassDescriptor using a value field Dim pFDescr As IFeatureClassDescriptor Set pFDescr = New FeatureClassDescriptor ''' This string "Elevation" must be a field in your featureclass '' this value will be used to interpolate. Or substitute a field '' name that does exist. pFDescr.Create pFClass, Nothing, "Elevation" ' Create RasterInterpolationOp object Dim pIntOp As IInterpolationOp Set pIntOp = New RasterInterpolationOp ' Set cell size for output raster. The extent of the output raster is ' defualted to as same as input. The output working directory uses Default Dim pEnv As IRasterAnalysisEnvironment Set pEnv = pIntOp pEnv.SetCellSize esriRasterEnvValue, pREnv.Width / 250 pEnv.SetExtent esriRasterEnvValue, pREnv ' Create raster radius using variable distance Dim pRadius As IRasterRadius Set pRadius = New RasterRadius pRadius.SetVariable 12 ' Using FeatureClassDescriptor as an input to the IInterpolationOp and ' Perform the interpolation Dim pOutRaster As IRaster Set pOutRaster = pIntOp.IDW(pFDescr, 2, pRadius) Dim strData As String '''Notice the GRID will be named "MyIDW" strData = "C:\temp\MyIDW" Call createFileFromRaster(pOutRaster, strData)
Code: Sub createFileFromRaster(pRaster As IRaster, OutFN As String) Dim prasterBandC As IRasterBandCollection Set prasterBandC = pRaster prasterBandC.SaveAs OutFN, Nothing, "GRID" End Sub
Note: The library must be added, or the procedure will not work.
Get help from ArcGIS experts
Download the Esri Support App