码迷,mamicode.com
首页 > 其他好文 > 详细

克里金插值及栅格渲染

时间:2014-10-09 16:56:57      阅读:1302      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   color   io   os   ar   for   sp   

bubuko.com,布布扣

1、首先写一个栅格渲染的方法:

步骤:1计算立方图 2创建色带 3渲染

  //渲染
        private void Renders(IRasterLayer layer)
        {
            IRasterClassifyColorRampRenderer classRender = new RasterClassifyColorRampRendererClass();

           
            IRasterRenderer rasterRender = classRender as IRasterRenderer;
            IRaster raster = layer.Raster;
            IRasterBandCollection collection = raster as IRasterBandCollection;
            IRasterBand rasterBand = collection.Item(0);
            if (rasterBand.Histogram == null)
            {
                rasterBand.ComputeStatsAndHist();//计算立方图 
            }

            classRender.ClassCount = 8;
          

            IAlgorithmicColorRamp ramp = new AlgorithmicColorRampClass();
            ramp.FromColor = GetColor(255, 0, 0);
            ramp.ToColor = GetColor(0, 255, 0);
            ramp.Size = 8;
            bool ok=true;
            ramp.CreateRamp(out ok);

            IFillSymbol fillSymbol = new SimpleFillSymbolClass();
            for (int i = 0; i < classRender.ClassCount; i++)
            {
                fillSymbol.Color = ramp.get_Color(i);  //不能用ramp.colors.Next()
                classRender.set_Symbol(i, fillSymbol as ISymbol);
                classRender.set_Label(i, "class" + i.ToString());

            }
            IRasterRenderer render = classRender as IRasterRenderer;
            render.Update();
            layer.Renderer = classRender as IRasterRenderer;
        }

2克里金插值,与IDW插值类似

private void kringToolStripMenuItem_Click(object sender, EventArgs e)
        {
         
            IGeoDataset geodataset = axMapControl1.get_Layer(0) as IGeoDataset;
            object Etn=geodataset.Extent;
            IFeatureLayer layer = axMapControl1.get_Layer(0) as IFeatureLayer;
            IFeatureClassDescriptor descriptor = new FeatureClassDescriptorClass();
            descriptor.Create(layer.FeatureClass, null, "value");

            IRasterRadius radius = new RasterRadiusClass();
            object missing = null;
            radius.SetVariable(12, ref missing);
            //double dSearch=10;
            //object dSearchCount=3;
            //radius.SetFixed(dSearch, ref dSearchCount);

            IInterpolationOp interpolation = new RasterInterpolationOpClass();

            object CellSize=15;
            IRasterAnalysisEnvironment environment = interpolation as IRasterAnalysisEnvironment;
            environment.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref CellSize);
            environment.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref Etn, ref missing);

            IGeoDataset dataset=   interpolation.Krige((IGeoDataset)descriptor, esriGeoAnalysisSemiVariogramEnum.esriGeoAnalysisSphericalSemiVariogram, radius, false, ref missing);
            MessageBox.Show("插值成功!");
            IRaster raster = new ESRI.ArcGIS.DataSourcesRaster.Raster();
            raster = dataset as IRaster;
            IRasterLayer rasterlayer = new RasterLayerClass();
            rasterlayer.CreateFromRaster(raster);
            Renders(rasterlayer);
            axMapControl1.AddLayer(rasterlayer);
          
            MessageBox.Show("插值成功!");

 

           
        }


      

克里金插值及栅格渲染

标签:des   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/GiserNet/p/4013332.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!