AE IDW插值

转自:http://www.3snews.net/html/13/15413-24268.html

 

 private void iDW插值ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IFeatureLayer pLayer = axMapControl1.get_Layer(0) as IFeatureLayer;
            //IFeatureLayer pExtentLyr = axMapControl1.get_Layer(1) as IFeatureLayer;
            //IFeatureClass pExtentClass = pExtentLyr.FeatureClass;
            IFeatureClass pFtClass = pLayer.FeatureClass;

            IRasterRadius pRsterRiadius = new RasterRadiusClass();
            int count=12;
            object MaxDistance=Type.Missing;
            pRsterRiadius.SetVariable(count, ref MaxDistance);

            IFeatureClassDescriptor pDes = new FeatureClassDescriptorClass();
            pDes.Create(pFtClass, null, "avg");

            IInterpolationOp2 pInterOP=new RasterInterpolationOpClass();
            IRasterAnalysisEnvironment pEnv = new RasterAnalysisClass();
            pEnv = pInterOP as IRasterAnalysisEnvironment;
            object cellsize=2048; //栅格大小
            pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue    , ref cellsize);
           
            IGeoDataset pGeo = pFtClass   as IGeoDataset;
            object extent=pGeo.Extent;
            object missing = Type.Missing;
            pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvMaxOf   , ref extent, ref missing);

            IRaster pRaster;
            IRasterLayer pRasterLyr = new RasterLayerClass();
            IGeoDataset pGeoDataSet;
            object Barrier=Type.Missing;
            pGeoDataSet = pInterOP.IDW((IGeoDataset)pDes, 2, pRsterRiadius, ref Barrier);
            MessageBox.Show("插值生成,请等待加载图层....");
            pRaster = pGeoDataSet as IRaster;
            pRasterLyr.CreateFromRaster(pRaster);

            //axMapControl1.ClearLayers();
            axMapControl1.AddLayer(pRasterLyr);
            MessageBox.Show("加载成功,请等待分级渲染.....");

            //开始渲染
            IMap pMap = axMapControl1.Map;
            IRasterLayer pRasterlayer = pMap.get_Layer(0) as RasterLayer;
            IRaster pRaster1;
            pRaster1 = pRasterlayer.Raster;
            IRasterClassifyColorRampRenderer pClassRender = new RasterClassifyColorRampRendererClass();
            IRasterRenderer pRasterRender = pClassRender as IRasterRenderer;
            pRasterRender.Raster = pRaster;
            pClassRender.ClassCount = 10;
            pRasterRender.Update();
            IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass();
            pRamp.FromColor = GetColor(225, 0, 128) as IColor;
            pRamp.ToColor = GetColor(135, 42, 8) as IColor;
            pRamp.Size = 10;
            bool K = true;
            pRamp.CreateRamp(out OK);
            ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            for (int i = 0; i < pClassRender.ClassCount; i++)
            {
                pFillSymbol.Color = pRamp.get_Color(i);
                pClassRender.set_Symbol(i, pFillSymbol as ISymbol);
                pClassRender.set_Label(i, "等级" + Convert.ToString(i + 1));
            }
            pRasterRender.Update();
            pRasterLyr.Renderer = pClassRender as IRasterRenderer;
            axMapControl1.ActiveView.Refresh();
            MessageBox.Show("成功生成!");
            axTOCControl1.Update();



           
        }

你可能感兴趣的:(object,null,layer)