IDW Spatial Analyst(ESRI.ArcGIS.SpatialAnalystTools)ArcEngine中反距离加权插值方法

IDW(反距离加权插值方法)

public void GPIDW(AxMapControl mapControl, ILayer layer, IEnvelope e, string pField, bool ISUPPER, string tucengname, double rasterPixel, double dInterval, ISpatialReference spatialReference_Un, string prj_name) 

        {

 Geoprocessor GP = new Geoprocessor();

            ESRI.ArcGIS.SpatialAnalystTools.Idw pIdw = new ESRI.ArcGIS.SpatialAnalystTools.Idw();
            pIdw.in_point_features = ls_TempSavePath + "HistoryData\\" + layer.Name + ".shp";
            pIdw.z_field = pField;
            string outputfile = "idw_new"+DateTime.Now.Millisecond.ToString();
            pIdw.out_raster = ls_TempSavePath + outputfile;
            GP.Execute(pIdw, null);
            IRaster pOutRaster = default(IRaster);
                          
            IRasterLayer rasterLayer = new RasterLayerClass();
            rasterLayer.CreateFromFilePath(ls_TempSavePath + outputfile);
            pOutRaster = rasterLayer.Raster;

             GPcontour(mapControl, spatialReference_Un, pOutRaster, tucengname, ls_TempSavePath, rasterPixel, dInterval, ISUPPER, layer.Name, prj_name)
        }
        
        private void GPcontour( AxMapControl mapControl, ISpatialReference spatialReference_Un, IRaster pOutRaster, string tucengname, string ls_TempSavePath, double rasterPixel, double dInterval, bool ISUPPER, string layerName_, string prj_name)
        {
            //Add output into ArcMap as a raster layer    
            IRasterLayer pOutRasLayer = new RasterLayerClass();
            pOutRasLayer.SpatialReference = spatialReference_Un;
            pOutRasLayer.CreateFromRaster(pOutRaster);
            pOutRasLayer.Name = tucengname + "栅格";


            Geoprocessor GP = new Geoprocessor();
            ESRI.ArcGIS.Analyst3DTools.Contour pContour = new Contour();
            pContour.contour_interval = dInterval;
            pContour.in_raster = pOutRaster;
            string outputfile = ""+DateTime.Now.Millisecond.ToString();
            string uniqueStr = DateTime.Now.Millisecond.ToString();
            pContour.out_polyline_features = ls_TempSavePath + layerName_ + "等值线" + uniqueStr; 
            GP.Execute(pContour, null);
            MainMapHelper mmh = new MainMapHelper();
            string fullpath = ls_TempSavePath + layerName_ + "等值线" + uniqueStr + ".shp";
            ILayer plyr =mmh.LoadExistDrillShp(fullpath);
            if (plyr == null) { return; }
            //添加标注
            IFeatureLayer pFeatlyr = plyr as IGeoFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pFeatlyr as IGeoFeatureLayer;
            pGeoFeatureLayer.Name = layerName_ + "等值线";
            pGeoFeatureLayer.DisplayAnnotation = true;
            pGeoFeatureLayer.DisplayField = "Contour";
            pGeoFeatureLayer.SpatialReference = spatialReference_Un;


            IMap m_pMap = mapControl.Map;
            IGroupLayer dzxsj_glayer = new GroupLayerClass();
            dzxsj_glayer.Name = "等值线数据";
            dzxsj_glayer.Add(pGeoFeatureLayer);
            pOutRasLayer.Visible = false;
            dzxsj_glayer.Add(pOutRasLayer);


            ILayer dzdpLayer = null;
            for (int i = 0; i < m_pMap.LayerCount; i++)
            {
                if (m_pMap.get_Layer(i).Name == "等值线数据")
                {
                    IGroupLayer glayer = m_pMap.get_Layer(i) as IGroupLayer;
                    ICompositeLayer pGL = glayer as ICompositeLayer;
                    for (int j = 0; j < pGL.Count; j++)
                    {
                        if (pGL.get_Layer(j).Name == layerName_)
                        {
                            dzdpLayer = pGL.get_Layer(j);
                            break;
                        }
                    }
                    mapControl.DeleteLayer(i);
                }
            }
            if (dzdpLayer != null)
                dzxsj_glayer.Add(dzdpLayer);
            mapControl.AddLayer(dzxsj_glayer, m_pMap.LayerCount - 1);
            mapControl.Refresh();
        }

你可能感兴趣的:(IDW Spatial Analyst(ESRI.ArcGIS.SpatialAnalystTools)ArcEngine中反距离加权插值方法)