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

关于IDW空间插值

时间:2014-10-09 01:59:57      阅读:688      评论:0      收藏:0      [点我收藏+]

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

空间插值一般都会用到IInterPolationOP接口等

bubuko.com,布布扣bubuko.com,布布扣

首先是通过图层的名称获取图层的方法:

 private ILayer GetLayerByName(string name)
        {
            ILayer layer = null;
            for (int i = 0; i < axmapcontrol.Map.LayerCount; i++)
            {
                if (name == axmapcontrol.Map.Layer[i].Name)
                {
                    layer = axmapcontrol.Map.get_Layer(i);
                    break;
                }

            }
            return layer;
        }

进行插值:

 string layerName = comboBox1.SelectedItem.ToString();
            string fieldName = comboBox2.SelectedItem.ToString();
            object CellSize = textBox1.Text;
            IFeatureLayer layer = GetLayerByName(layerName) as IFeatureLayer;
            IGeoDataset geoLayer=GetLayerByName(layerName) as IGeoDataset;
            object  Env=  geoLayer.Extent;

            IFeatureClassDescriptor descriptor = new FeatureClassDescriptorClass();
            descriptor.Create(layer.FeatureClass, null, fieldName); //处理转换的字段

         
            object ob = null;

            IRasterRadius radius = new RasterRadiusClass();//设置半径
            object maxDistance = null;
            radius.SetVariable(12, ref maxDistance);

            IInterpolationOp interpolation = new RasterInterpolationOpClass();
            IRasterAnalysisEnvironment environment = interpolation as IRasterAnalysisEnvironment;
            environment.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref CellSize);//设置像元大小
            environment.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref Env, ref ob);//设置插值的范围

            IGeoDataset dataset1= interpolation.IDW((IGeoDataset)descriptor, 2, radius, ref maxDistance);//执行插值


            IRaster raster = new ESRI.ArcGIS.DataSourcesRaster.Raster();//添加到图层
            raster = dataset1 as IRaster;
            IRasterLayer rasterLayer = new RasterLayerClass();
            rasterLayer.CreateFromRaster(raster);
            rasterLayer.Name = "IDWraster";
            axmapcontrol.AddLayer(rasterLayer);

            MessageBox.Show("插值成功");
           

 

关于IDW空间插值

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

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

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