public static void Mlayer_Krige_Click() { // 用克里金Krige插值生成的栅格图像。如下: IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); string pPath = Application.StartupPath + @"\MakeContours\Cont.shp"; string pFolder = System.IO.Path.GetDirectoryName(pPath); string pFileName = System.IO.Path.GetFileName(pPath); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(pFolder, 0); IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; IFeatureClass oFeatureClass = pFeatureWorkspace.OpenFeatureClass(pFileName); IFeatureClassDescriptor pFCDescriptor = new FeatureClassDescriptorClass(); pFCDescriptor.Create(oFeatureClass, null, "shape.z"); IInterpolationOp pInterpolationOp = new RasterInterpolationOpClass(); IRasterAnalysisEnvironment pEnv = pInterpolationOp as IRasterAnalysisEnvironment; object Cellsize = 0.004;//Cell size for output raster;0.004 pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref Cellsize); //设置输出范围 //27202 19104;27202 22947;31550 22947;31550 19104 object snapRasterData = Type.Missing; IEnvelope pExtent; pExtent = new EnvelopeClass(); Double xmin = 27202; Double xmax = 31550; Double ymin = 19104; Double ymax = 22947; pExtent.PutCoords(xmin, ymin, xmax, ymax); object extentProvider = pExtent; pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extentProvider, ref snapRasterData); Double dSearchD = 10; object pSearchCount = 3; object missing = Type.Missing; IRasterRadius pRadius = new RasterRadius(); pRadius.SetFixed(dSearchD, ref pSearchCount); //pRadius.SetVariable((int)pSearchCount, ref dSearchD); IGeoDataset poutGeoDataset = pInterpolationOp.Krige((IGeoDataset)pFCDescriptor, esriGeoAnalysisSemiVariogramEnum.esriGeoAnalysisGaussianSemiVariogram, pRadius, false, ref missing); IRaster pOutRaster = poutGeoDataset as IRaster; IRasterLayer pOutRasLayer = new RasterLayer(); pOutRasLayer.CreateFromRaster(pOutRaster); IMap pMap = Common.DataEditCommon.g_pMap; pMap.AddLayer(pOutRasLayer); Common.DataEditCommon.g_axTocControl.Refresh(); Common.DataEditCommon.g_pAxMapControl.ActiveView.Refresh(); }