HOW TO
Note: This article pertains to ArcGIS versions 8.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
This VBA code sample illustrates to use IInterpolationOp's Krige method.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Code: 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 pInput As IGeoDataset Set pInput = pFClass Dim pFeatureClassDescriptor As IFeatureClassDescriptor Set pFeatureClassDescriptor = New FeatureClassDescriptor '********************************************************** ''Change the string value ("height") to a field name in the featureclass. pFeatureClassDescriptor.Create pFClass, Nothing, "height" '********************************************************** Dim pAV As IActiveView Set pAV = pMap Dim pREnv As IEnvelope Set pREnv = pAV.Extent '**************************************************************** ' 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 ' Use FeatureClassDescriptor as an input to the IInterpolationOp ' Perform the interpolation Dim pOutRaster As IRaster Set pOutRaster = pIntOp.Krige(pFeatureClassDescriptor, esriGeoAnalysisUniversal1SemiVariogram, pRadius, True) Dim strData As String ''' The output GRID will be named "MyRaster" strData = "C:\temp\MyRaster" 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
Get help from ArcGIS experts
Download the Esri Support App