Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            IGeoDataset inGeoDataSet;
            IGeoDataset outGeoDataSet;
            ISurfaceOp  SurfaceOp = new RasterSurfaceOpClass();

            ILayer       layer       = GetLayerByName(comboBox1.SelectedItem.ToString());
            IRasterLayer rasterLayer = layer as IRasterLayer;
            IRaster      raster      = rasterLayer.Raster;

            inGeoDataSet = raster as IGeoDataset;

            outGeoDataSet = SurfaceOp.Aspect(inGeoDataSet);

            try
            {
                IWorkspaceFactory pWKSF      = new RasterWorkspaceFactoryClass();
                IWorkspace        pWorkspace = pWKSF.OpenFromFile(System.IO.Path.GetDirectoryName(textBox1.Text), 0);
                ISaveAs           pSaveAs    = outGeoDataSet as ISaveAs;
                pSaveAs.SaveAs(System.IO.Path.GetFileName(textBox1.Text), pWorkspace, "TIFF");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            IRasterLayer pRlayer = new RasterLayer();

            pRlayer.CreateFromRaster((IRaster)outGeoDataSet);
            pRlayer.Name = System.IO.Path.GetFileName(textBox1.Text);
            mainForm.axMapControl1.AddLayer(pRlayer, 0);
        }
Ejemplo n.º 2
0
        public static void Mlayer_IDW_Click()
        {
            // 用反距离IDW插值生成的栅格图像。如下:
            IInterpolationOp pInterpolationOp = new RasterInterpolationOpClass();

            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");
            IRasterRadius pRadius = new RasterRadiusClass();

            object objectMaxDistance = null;
            object objectbarrier     = null;
            object missing           = Type.Missing;

            pRadius.SetVariable(12, ref objectMaxDistance);

            object    dCellSize      = 1;
            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;
            IRasterAnalysisEnvironment pEnv = pInterpolationOp as IRasterAnalysisEnvironment;

            pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref dCellSize);
            pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extentProvider, ref snapRasterData);
            IGeoDataset poutGeoDataset = pInterpolationOp.IDW((IGeoDataset)pFCDescriptor, 2, pRadius, ref objectbarrier);
            ISurfaceOp  surOp          = new RasterSurfaceOpClass();


            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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        private void btnok_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.DataManagementTools.MosaicToNewRaster m2nr = new MosaicToNewRaster();
            m2nr.input_rasters   = GetLayerList();
            m2nr.output_location = System.IO.Path.GetDirectoryName(textbaocun.Text);
            m2nr.pixel_type      = xiangsuleixing.Text;
            m2nr.number_of_bands = Convert.ToInt32(boduanshu.Text);
            m2nr.raster_dataset_name_with_extension = System.IO.Path.GetFileName(textbaocun.Text);
            m2nr.mosaic_method        = xiangyun.Text;
            m2nr.mosaic_colormap_mode = xiangsebiao.Text;

            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            IGeoProcessorResult gpResult = gp.Execute(m2nr, null) as IGeoProcessorResult;

            if (gpResult.Status == esriJobStatus.esriJobSucceeded)
            {
                DialogResult dr = MessageBox.Show("数据镶嵌操作成功");
                if (dr == DialogResult.OK)
                {    //结果添加到工作空间
                    if (addresult.Checked == true)
                    {
                        string fileFullName = textbaocun.Text;
                        if (fileFullName == "")
                        {
                            return;
                        }
                        string            filePathName      = System.IO.Path.GetDirectoryName(fileFullName);
                        string            fileName          = System.IO.Path.GetFileName(fileFullName);
                        IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();                    //创建工作空间工厂
                        IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(filePathName, 0); //打开工作空间
                        IRasterWorkspace  pRasterWorkspace  = pWorkspace as IRasterWorkspace;                  //创建栅格工作空间
                        IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(fileName);    //创建Dataset
                        //影像金字塔创建与判断
                        IRasterPyramid2 pRasPymid = pRasterDataset as IRasterPyramid2;
                        if (pRasPymid != null)
                        {
                            if (!(pRasPymid.Present))
                            {
                                pRasPymid.Create();//创建金字塔
                            }
                        }
                        IRaster      pRaster      = pRasterDataset.CreateDefaultRaster();
                        IRasterLayer pRasterLayer = new RasterLayer();
                        pRasterLayer.CreateFromRaster(pRaster);
                        ILayer pLayer = pRasterLayer as ILayer;
                        axmapcontrol.AddLayer(pLayer, 0);
                    }
                }
            }
            else
            {
                MessageBox.Show("数据镶嵌操作失败");
            }
        }
Ejemplo n.º 5
0
        private void button4_Click(object sender, EventArgs e)
        {
            CompositeBands cb = new CompositeBands();

            cb.in_rasters = GetLayerList();
            cb.out_raster = textBox1.Text;
            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            IGeoProcessorResult gpResult = gp.Execute(cb, null) as IGeoProcessorResult;

            if (gpResult.Status == esriJobStatus.esriJobSucceeded)
            {
                DialogResult dr = MessageBox.Show("波段合成成功");
                if (dr == DialogResult.OK)
                {    //结果添加到工作空间
                    if (checkBox1.Checked == true)
                    {
                        string fileFullName = textBox1.Text;
                        if (fileFullName == "")
                        {
                            return;
                        }
                        string            filePathName      = System.IO.Path.GetDirectoryName(fileFullName);
                        string            fileName          = System.IO.Path.GetFileName(fileFullName);
                        IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();                    //创建工作空间工厂
                        IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(filePathName, 0); //打开工作空间
                        IRasterWorkspace  pRasterWorkspace  = pWorkspace as IRasterWorkspace;                  //创建栅格工作空间
                        IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(fileName);    //创建Dataset
                        //影像金字塔创建与判断
                        IRasterPyramid2 pRasPymid = pRasterDataset as IRasterPyramid2;
                        if (pRasPymid != null)
                        {
                            if (!(pRasPymid.Present))
                            {
                                pRasPymid.Create();//创建金字塔
                            }
                        }
                        IRaster      pRaster      = pRasterDataset.CreateDefaultRaster();
                        IRasterLayer pRasterLayer = new RasterLayer();
                        pRasterLayer.CreateFromRaster(pRaster);
                        ILayer pLayer = pRasterLayer as ILayer;
                        axmapcontrol.AddLayer(pLayer, 0);
                    }
                }
            }
            else
            {
                MessageBox.Show("波段合成失败");
            }
        }
Ejemplo n.º 6
0
        private void button3_Click(object sender, EventArgs e)
        {
            string inputFullFilePath  = textBox1.Text;
            string outputFullFilePath = textBox2.Text;
            // deal with the outputFullFilePath
            int    _index                = outputFullFilePath.LastIndexOf("\\");
            string outputRasterName      = (outputFullFilePath.Substring(_index + 1)); //name
            string outputRasterDirectory = outputFullFilePath.Remove(_index);          //directory

            //deal with input
            IRasterLayer pRasterLayer = new RasterLayerClass();

            pRasterLayer.CreateFromFilePath(inputFullFilePath);
            IRaster raster = pRasterLayer.Raster;

            IMapAlgebraOp mapAlgebraOp;

            mapAlgebraOp = new RasterMapAlgebraOpClass();
            //控制raster分析的环境
            IRasterAnalysisEnvironment rasterAnalysisEnvironment = default(IRasterAnalysisEnvironment);

            rasterAnalysisEnvironment = (IRasterAnalysisEnvironment)mapAlgebraOp;

            IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactoryClass();
            IWorkspace        workspace        = workspaceFactory.OpenFromFile(outputRasterDirectory, 0);//这里应该是输出raster的路径

            rasterAnalysisEnvironment.OutWorkspace = workspace;

            try
            {
                mapAlgebraOp.BindRaster((IGeoDataset)raster, "this");
                //定义表达式(elevationMode为要减去的数值)不要忘了"[ ]"
                //"CON(ISNULL([this]),0,[this])"
                //"~(([this]>=92)&([this]<=272))&([this]>=2)"
                string   strOut    = textBox3.Text;
                IRaster  outRaster = (IRaster)mapAlgebraOp.Execute(strOut);
                ISaveAs2 saveAs;
                saveAs = (ISaveAs2)outRaster;
                saveAs.SaveAs(outputRasterName, workspace, "TIFF");//输出名称(注意:名称中加后缀名,例:test.tif),工作空间,格式
                MessageBox.Show("栅格计算器成功!");

                IRasterLayer pRlayer = new RasterLayer();
                pRlayer.CreateFromRaster(outRaster);
                pRlayer.Name = System.IO.Path.GetFileName(outputFullFilePath);
                mainForm.axMapControl1.AddLayer(pRlayer, 0);
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 7
0
        private Rectangle MouseRect = Rectangle.Empty; //初始化矩形裁剪包络线时

        #endregion 私有成员变量

        /// <summary>
        /// 打开栅格文件.
        /// </summary>
        /// <param name="rasfilename">栅格文件路径</param>
        public void openRasterFile(string rasfilename)
        {
            FileInfo finfo = new FileInfo(rasfilename);

            if (!finfo.Exists)
            {
                return;                // 文件不存在,返回
            }
            IWorkspaceFactory pWorkspaceFacotry = new RasterWorkspaceFactory();

            IWorkspace       pWorkspace       = pWorkspaceFacotry.OpenFromFile(finfo.DirectoryName, 0);
            IRasterWorkspace pRasterWorkspace = pWorkspace as IRasterWorkspace;
            IRasterDataset   pRasterDataset   = pRasterWorkspace.OpenRasterDataset(finfo.Name);

            // 影像金字塔的判断与创建
            IRasterPyramid pRasterPyamid = pRasterDataset as IRasterPyramid;

            if (pRasterPyamid != null)
            {
                if (!(pRasterPyamid.Present))
                {
                    pRasterPyamid.Create();
                }
            }
            // 多波段图像
            IRasterBandCollection pRasterBands = (IRasterBandCollection)pRasterDataset;
            int     pBandCount = pRasterBands.Count;
            IRaster pRaster    = null;

            if (pBandCount > 3)
            {
                pRaster = (pRasterDataset as IRasterDataset2).CreateFullRaster();
            }
            else
            {
                pRaster = pRasterDataset.CreateDefaultRaster();
            }

            IRasterLayer pRasterLayer = new RasterLayer();

            pRasterLayer.CreateFromRaster(pRaster);
            pBandCount = pRasterLayer.BandCount;

            ILayer pLayer = pRasterLayer as ILayer;

            m_mapControl.AddLayer(pLayer);
            m_mapControl.Refresh();
        }
Ejemplo n.º 8
0
        // RasterModel ger möjlighet för klassificering, ändring av värden m.m.
        public void rasterModel(List <IRasterLayer> rList, List <string> sList1, List <string> sList2, string script, string rName)
        {
            IRasterModel rasterModel = new RasterModelClass();

            IRasterAnalysisEnvironment env = (IRasterAnalysisEnvironment)rasterModel;
            IWorkspaceFactory          workspaceFactory = new RasterWorkspaceFactoryClass();
            IWorkspace workspace = workspaceFactory.OpenFromFile(@"H:\VT2019\GIS_App\Projekt\Program\Data\UtData\Raster", 0);

            env.OutWorkspace = workspace;

            rasterModel.Script = script;

            for (int i = 0; i < rList.Count; i++)
            {
                rasterModel.BindRaster(rList[i].Raster, sList1[i]);
            }

            rasterModel.Execute();
            IRaster rResult1 = rasterModel.get_BoundRaster(sList2[sList2.Count - 1]);

            for (int i = 0; i < sList1.Count; i++)
            {
                rasterModel.UnbindSymbol(sList1[i]);
            }

            IRasterLayer newRaster = new RasterLayer();

            newRaster.CreateFromRaster(rResult1);
            newRaster.Name = rName;
            map.AddLayer(newRaster);

            switch (rName)
            {
            case "Kostnadsraster":
                cost = newRaster;
                //map.DeleteLayer(newRaster);
                break;

            case "Osäkra platser":
                source = newRaster;
                break;

            case "Säkra platser":
                dest = newRaster;
                break;
            }
        }
Ejemplo n.º 9
0
        private void 打开栅格数据ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openfiledialog = new OpenFileDialog();

            openfiledialog.CheckFileExists  = true;
            openfiledialog.Title            = @"打开栅格数据";
            openfiledialog.Filter           = @"tif文件(*.tif)|*.tif;|tiff文件(*.tiff)|*.tiff;|jpeg文件(*.jpeg)|*.jpeg;|jpg文件(*.jpg)|*.jpg;|png文件(*.png)|*.png;|bmp文件(*.bmp)|*.bmp;|img文件(*.img)|*.img";
            openfiledialog.RestoreDirectory = true;
            openfiledialog.ShowDialog();

            string pFullPath = openfiledialog.FileName;

            if (pFullPath == "")
            {
                return;
            }
            int    pIndext  = pFullPath.LastIndexOf("\\");
            string filePath = pFullPath.Substring(0, pIndext);
            string filename = pFullPath.Substring(pIndext + 1);


            IWorkspaceFactory pworkspacefacory = new RasterWorkspaceFactory(); //引用Geodatabase + DataSourceRaster
            IWorkspace        ws  = pworkspacefacory.OpenFromFile(filePath, 0);
            IRasterWorkspace  rws = ws as IRasterWorkspace;                    //强制转换
            IRasterDataset    rds = rws.OpenRasterDataset(filename);

            //影像金字塔的判断和创建(可有可无。创建金字塔的目的是减少时间)
            IRasterPyramid rp = rds as IRasterPyramid;

            if (rp != null)
            {
                if (!(rp.Present))
                {
                    rp.Create();
                }
            }

            //新建栅格图层
            IRasterLayer rl = new RasterLayer();//引用Carto

            rl.CreateFromRaster(rds.CreateDefaultRaster());
            //加载显示
            axMapControl1.AddLayer(rl, 0);
            axMapControl1.ActiveView.Refresh();
        }
Ejemplo n.º 10
0
 public static IRasterLayer SetStretchRenderer(IRaster pRaster)
 {
     try
     {
         //创建着色类和QI栅格着色
         IRasterStretchColorRampRenderer pStretchRen = new RasterStretchColorRampRenderer();
         IRasterRenderer pRasRen = pStretchRen as IRasterRenderer;
         //为着色和更新设置栅格数据
         pRasRen.Raster = pRaster;
         pRasRen.Update();
         //定义起点和终点颜色
         IColor    pFromColor = new RgbColor();
         IRgbColor pRgbColor  = pFromColor as IRgbColor;
         pRgbColor.Red   = 255;
         pRgbColor.Green = 0;
         pRgbColor.Blue  = 0;
         IColor pToColor = new RgbColor();
         pRgbColor       = pToColor as IRgbColor;
         pRgbColor.Red   = 0;
         pRgbColor.Green = 255;
         pRgbColor.Blue  = 0;
         //创建颜色分级
         IAlgorithmicColorRamp pRamp = new AlgorithmicColorRamp();
         pRamp.Size      = 255;
         pRamp.FromColor = pFromColor;
         pRamp.ToColor   = pToColor;
         bool ok = true;
         pRamp.CreateRamp(out ok);
         //把颜色分级插入着色中并选择一个波段
         pStretchRen.BandIndex = 0;
         pStretchRen.ColorRamp = pRamp;
         pRasRen.Update();
         IRasterLayer pRLayer = new RasterLayer();
         pRLayer.CreateFromRaster(pRaster);
         pRLayer.Renderer = pStretchRen as IRasterRenderer;
         return(pRLayer);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 打开栅格数据
        /// </summary>
                private void openShanGe(string Path)
        {
            string RasterPath = System.IO.Path.GetDirectoryName(Path);
            string RasterName = System.IO.Path.GetFileName(Path);
                        //工作空间实例化
                        IWorkspaceFactory pRasterWsF = new RasterWorkspaceFactory();
            IWorkspace                 pWs           = pRasterWsF.OpenFromFile(RasterPath, 0);
            IRasterWorkspace           pRasterWs     = pWs as IRasterWorkspace;
                        IRasterDataset pRasterDS     = pRasterWs.OpenRasterDataset(RasterName);
                        //影像金字塔的判断和创建
                        IRasterPyramid pRasterPyramid = pRasterDS as IRasterPyramid;

            if ((pRasterPyramid != null) && (!pRasterPyramid.Present))
            {
                if (MessageBox.Show("是否开始创建金字塔?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.OK)
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    //开始
                    pRasterPyramid.Create();
                    //结束
                    sw.Stop();
                    MessageBox.Show("创建完成,Time:" + sw.ElapsedMilliseconds.ToString() + "ms");
                }
                else
                {
                    MessageBox.Show("放弃创建金字塔");
                }
            }
                        //新建栅格图层
                        IRasterLayer pRasterLayer = new RasterLayer();
                        pRasterLayer.CreateFromRaster(pRasterDS.CreateDefaultRaster());

            IMap pmap = mapControl.Map;
                        //加载显示
            pmap.AddLayer(pRasterLayer);

                        //mapControl.AddLayer(pRasterLayer, 0);
            mapControl.ActiveView.Refresh();

            OpenStatus();
        }
Ejemplo n.º 12
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "")
     {
         if (textBox1.Text != "")
         {
             ESRI.ArcGIS.DataManagementTools.CopyRaster copyRst = new CopyRaster();
             copyRst.in_raster         = getlayer(comboBox1.Text);
             copyRst.out_rasterdataset = textBox1.Text.ToString();
             Geoprocessor gp = new Geoprocessor();
             gp.OverwriteOutput = true;
             IGeoProcessorResult gpresult = gp.Execute(copyRst, null) as IGeoProcessorResult;
             if (gpresult.Status == esriJobStatus.esriJobSucceeded)
             {
                 DialogResult dr = MessageBox.Show("格式转化操作成功");
                 if (dr == DialogResult.OK)
                 {    //结果添加到工作空间
                     if (checkBox1.Checked == true)
                     {
                         string fileFullName = textBox1.Text;
                         if (fileFullName == "")
                         {
                             return;
                         }
                         string            filePathName      = System.IO.Path.GetDirectoryName(fileFullName);
                         string            fileName          = System.IO.Path.GetFileName(fileFullName);
                         IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();                    //创建工作空间工厂
                         IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(filePathName, 0); //打开工作空间
                         IRasterWorkspace  pRasterWorkspace  = pWorkspace as IRasterWorkspace;                  //创建栅格工作空间
                         IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(fileName);    //创建Dataset
                         //影像金字塔创建与判断
                         IRasterPyramid2 pRasPymid = pRasterDataset as IRasterPyramid2;
                         if (pRasPymid != null)
                         {
                             if (!(pRasPymid.Present))
                             {
                                 pRasPymid.Create();//创建金字塔
                             }
                         }
                         IRaster      pRaster      = pRasterDataset.CreateDefaultRaster();
                         IRasterLayer pRasterLayer = new RasterLayer();
                         pRasterLayer.CreateFromRaster(pRaster);
                         ILayer pLayer = pRasterLayer as ILayer;
                         axmapcontrol.AddLayer(pLayer, 0);
                     }
                 }
             }
             else
             {
                 MessageBox.Show("格式转化操作失败");
             }
         }
         else
         {
             MessageBox.Show("保存路径不能为空");
         }
     }
     else
     {
         MessageBox.Show("输入栅格不能为空");
     }
 }
Ejemplo n.º 13
0
        private void BtnOK_Click(object sender, EventArgs e)
        {
            IReclassOp reCla;

            reCla = new RasterReclassOp() as IReclassOp;
            //为分类着色用
            IRemap       pRemap;
            INumberRemap pSRemap;

            pSRemap = new NumberRemap() as INumberRemap;

            for (int i = 1; i <= Convert.ToInt32(DataGridFilterData.VisibleRowCount - 1); i++)
            {
                String str;
                //DataGridFilterData.ce
                str = DataGridFilterData[i - 1, 0].ToString();

                float fvalue, tvalue;
                int   p;
                p      = str.LastIndexOf("~");
                fvalue = Convert.ToSingle(str.Substring(0, p));
                tvalue = Convert.ToSingle(str.Substring(p + 1, str.Length - p - 1));
                pSRemap.MapRange(fvalue, tvalue, i);
            }

            // pSRemap.MapValueToNoData(-9999)
            pRemap = (IRemap)pSRemap;

            IGeoDataset pOutputRaster = null;

            try
            {
                pOutputRaster = reCla.ReclassByRemap((IGeoDataset)pRster, pRemap, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            IRasterLayer pRlayer;

            pRlayer = new RasterLayer();
            pRlayer.CreateFromRaster((IRaster)pOutputRaster);
            pRlayer.Name = Name + "Reclass";
            IRaster ds;

            ds = (IRaster)pOutputRaster;
            IRasterLayer pla;

            pla = SetStretchRenderer(ds);
            IColorRamp pRamp;
            //获得色带
            int index = imgCmbSingleClassify.SelectedIndex;

            pRamp = AlgorithmicColorRamp(index, DataGridFilterData.VisibleRowCount - 1);
            //分级色带渲染
            SingleClassifyRender(pRlayer, DataGridFilterData.VisibleRowCount - 1, pRamp);
            FrmGISMain.mainMap.AddLayer(pRlayer, 0);
            //FrmGISMain.mainMap.AddLayer(pRlayer, 0);
            Oput(pRlayer);
            //Output(pRlayer);
        }
Ejemplo n.º 14
0
        private void btnok_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.DataManagementTools.CreatePansharpenedRasterDataset cpr = new CreatePansharpenedRasterDataset();

            string inraster            = GetLayerList(quanse.Text);
            string inpanchromaticimage = GetLayerList(duoguangpu.Text);

            cpr.in_raster             = inraster;
            cpr.in_panchromatic_image = inpanchromaticimage;
            cpr.out_raster_dataset    = textbaocun.Text;

            cpr.red_channel      = Convert.ToInt32(redboduan.Text.ToString());
            cpr.green_channel    = Convert.ToInt32(greenboduan.Text.ToString());
            cpr.blue_channel     = Convert.ToInt32(blueboduan.Text.ToString());
            cpr.infrared_channel = 1;

            cpr.red_weight         = Convert.ToDouble(redquanzhong.Text.ToString());
            cpr.green_weight       = Convert.ToDouble(greenquanzhong.Text.ToString());
            cpr.blue_weight        = Convert.ToDouble(bluequanzhong.Text.ToString());
            cpr.infrared_weight    = Convert.ToDouble(jinhongwaiquanzhong.Text.ToString());
            cpr.pansharpening_type = ronghefangfa.Text;
            cpr.sensor             = chuanganqi.Text;

            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            object obj = gp.Execute(cpr, null);
            IGeoProcessorResult gpResult = obj as IGeoProcessorResult;

            if (gpResult.Status == esriJobStatus.esriJobSucceeded)
            {
                DialogResult dr = MessageBox.Show("多波段合成操作成功");
                if (dr == DialogResult.OK)
                {    //结果添加到工作空间
                    if (addResult.Checked == true)
                    {
                        string fileFullName = textbaocun.Text;
                        if (fileFullName == "")
                        {
                            return;
                        }
                        string            filePathName      = System.IO.Path.GetDirectoryName(fileFullName);
                        string            fileName          = System.IO.Path.GetFileName(fileFullName);
                        IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();                    //创建工作空间工厂
                        IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(filePathName, 0); //打开工作空间
                        IRasterWorkspace  pRasterWorkspace  = pWorkspace as IRasterWorkspace;                  //创建栅格工作空间
                        IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(fileName);    //创建Dataset
                        //影像金字塔创建与判断
                        IRasterPyramid2 pRasPymid = pRasterDataset as IRasterPyramid2;
                        if (pRasPymid != null)
                        {
                            if (!(pRasPymid.Present))
                            {
                                pRasPymid.Create();//创建金字塔
                            }
                        }
                        IRaster      pRaster      = pRasterDataset.CreateDefaultRaster();
                        IRasterLayer pRasterLayer = new RasterLayer();
                        pRasterLayer.CreateFromRaster(pRaster);
                        ILayer pLayer = pRasterLayer as ILayer;
                        axmapcontrol.AddLayer(pLayer, 0);
                    }
                }
            }
            else
            {
                MessageBox.Show("多波段合成操作失败");
            }
        }
Ejemplo n.º 15
0
        public static void Mlayer_IDW_Click()
        {
            // 用反距离IDW插值生成的栅格图像。如下:
               IInterpolationOp pInterpolationOp = new RasterInterpolationOpClass();

               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");
               IRasterRadius pRadius = new RasterRadiusClass();

               object objectMaxDistance = null;
               object objectbarrier = null;
               object missing = Type.Missing;
               pRadius.SetVariable(12, ref objectMaxDistance);

               object dCellSize =1;
               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;
               IRasterAnalysisEnvironment pEnv = pInterpolationOp as IRasterAnalysisEnvironment;
               pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref dCellSize);
               pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extentProvider, ref snapRasterData);
               IGeoDataset poutGeoDataset = pInterpolationOp.IDW((IGeoDataset)pFCDescriptor, 2, pRadius, ref objectbarrier);
               ISurfaceOp surOp = new RasterSurfaceOpClass();

               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();
        }
Ejemplo n.º 16
0
        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();
        }
Ejemplo n.º 17
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                ILayer        selectedLayer        = global.p2DMap.get_Layer(comboBox1.SelectedIndex);
                IFeatureLayer selectedFeatureLayer = selectedLayer as IFeatureLayer;
                IFeatureClass selectedFeatureClass = selectedFeatureLayer.FeatureClass;

                IRasterAnalysisEnvironment rasterEnv = new RasterDensityOp();

                double r        = Convert.ToDouble(textBox2.Text);
                object dSearchD = r;  //搜索半径

                //设置输出栅格大小
                double cellSize = Convert.ToDouble(textBox3.Text);
                // object cellSizeObj = cellSize;
                // rasterEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeObj);

                //获得图层
                ILayer layer = null;
                IMap   map   = global.p2DMap;
                for (int i = 0; i < map.LayerCount; i++)
                {
                    ILayer temp = map.Layer[i];
                    if (temp.Name == comboBox1.SelectedItem.ToString())
                    {
                        layer = temp;
                    }
                }
                IFeatureLayer fLayer = layer as IFeatureLayer;
                IFeatureClass fClass = fLayer.FeatureClass;

                //设置空间处理范围
                object extentProObj = layer;
                rasterEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extentProObj);
                rasterEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, 1);
                // IRasterRadius pRadius = new RasterRadiusClass();??
                // pRadius.SetVariable(pSearchCount, ref dSearchD);


                //设置要素数据
                IFeatureClassDescriptor feaDes;
                feaDes = new FeatureClassDescriptorClass();
                feaDes.Create(fClass, null, comboBox2.SelectedItem.ToString());
                IGeoDataset inGeodataset;
                inGeodataset = feaDes as IGeoDataset;


                //设置输出栅格
                //IRaster outraster;
                IGeoDataset outGeoDataset;

                IDensityOp densityOp = rasterEnv as IDensityOp;
                outGeoDataset = densityOp.KernelDensity(inGeodataset, r);//., 1);

                try
                {
                    IWorkspaceFactory pWKSF      = new RasterWorkspaceFactoryClass();
                    IWorkspace        pWorkspace = pWKSF.OpenFromFile(System.IO.Path.GetDirectoryName(textBox1.Text), 0);
                    ISaveAs           pSaveAs    = outGeoDataset as ISaveAs;
                    pSaveAs.SaveAs(System.IO.Path.GetFileName(textBox1.Text), pWorkspace, "TIFF");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                IRasterLayer pRlayer = new RasterLayer();
                pRlayer.CreateFromRaster((IRaster)outGeoDataset);
                pRlayer.Name = System.IO.Path.GetFileName(textBox1.Text);
                global.p2DMap.AddLayer(pRlayer);
                global.p3DMap.Scene.AddLayer(pRlayer);
            }

            catch { }
            this.Close();
        }
Ejemplo n.º 18
0
        private void button2_Click(object sender, EventArgs e)
        {
            IReclassOp reCla;

            reCla = new RasterReclassOp() as IReclassOp;
            //符号化
            IRemap       pRemap;
            INumberRemap pSRemap;

            pSRemap = new NumberRemap() as INumberRemap;
            for (int i = 1; i <= Convert.ToInt32(comboBox2.SelectedItem.ToString()); i++)
            {
                try
                {
                    string str;
                    str = dataGridView1.Rows[i - 1].Cells[0].Value.ToString();
                    float fValue, tValue;
                    int   p;
                    p = str.LastIndexOf("-");

                    fValue = Convert.ToSingle(str.Substring(0, p));
                    tValue = Convert.ToSingle(str.Substring(p + 1, str.Length - p - 1));
                    pSRemap.MapRange(fValue, tValue, Convert.ToInt32(dataGridView1.Rows[i - 1].Cells[1].Value));
                }
                catch
                {
                    MessageBox.Show("Error!");
                    return;
                }
            }
            pRemap = (IRemap)pSRemap;

            //获取栅格图层
            IRasterLayer play          = (IRasterLayer)GetLayerByName(comboBox1.SelectedItem.ToString());
            IRaster      pRster        = play.Raster;
            IGeoDataset  pOutputRaster = null;

            try
            {
                pOutputRaster = reCla.ReclassByRemap((IGeoDataset)pRster, pRemap, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            try
            {
                IWorkspaceFactory pWKSF      = new RasterWorkspaceFactoryClass();
                IWorkspace        pWorkspace = pWKSF.OpenFromFile(System.IO.Path.GetDirectoryName(textBox1.Text), 0);
                ISaveAs           pSaveAs    = pOutputRaster as ISaveAs;
                pSaveAs.SaveAs(System.IO.Path.GetFileName(textBox1.Text), pWorkspace, "TIFF");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            IRasterLayer pRlayer = new RasterLayer();

            pRlayer.CreateFromRaster((IRaster)pOutputRaster);
            pRlayer.Name = System.IO.Path.GetFileName(textBox1.Text);
            global.p2DMap.AddLayer(pRlayer);
            global.p3DMap.Scene.AddLayer(pRlayer);
            mainForm.axTOCControl1.Update();
            mainForm.axTOCControl2.Update();
        }
Ejemplo n.º 19
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "")
     {
         if (textBox1.Text != "")
         {
             ESRI.ArcGIS.DataManagementTools.Resample rsp = new Resample();
             rsp.in_raster  = getlayer(comboBox1.Text);
             rsp.out_raster = textBox1.Text;
             //重采样技术
             rsp.resampling_type = comboBox2.Text;
             //重采样分辨率
             rsp.cell_size = Int32.Parse(textBox2.Text) * Int32.Parse(textBox3.Text);
             Geoprocessor gp = new Geoprocessor();
             gp.OverwriteOutput = true;
             object obj = gp.Execute(rsp, null);
             IGeoProcessorResult pgeoprcessorresult = obj as IGeoProcessorResult;
             if (pgeoprcessorresult.Status == esriJobStatus.esriJobSucceeded)
             {
                 DialogResult dr = MessageBox.Show("重采样操作成功");
                 if (dr == DialogResult.OK)
                 {    //结果添加到工作空间
                     if (checkBox1.Checked == true)
                     {
                         string fileFullName = textBox1.Text;
                         if (fileFullName == "")
                         {
                             return;
                         }
                         string            filePathName      = System.IO.Path.GetDirectoryName(fileFullName);
                         string            fileName          = System.IO.Path.GetFileName(fileFullName);
                         IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();                    //创建工作空间工厂
                         IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(filePathName, 0); //打开工作空间
                         IRasterWorkspace  pRasterWorkspace  = pWorkspace as IRasterWorkspace;                  //创建栅格工作空间
                         IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(fileName);    //创建Dataset
                         //影像金字塔创建与判断
                         IRasterPyramid2 pRasPymid = pRasterDataset as IRasterPyramid2;
                         if (pRasPymid != null)
                         {
                             if (!(pRasPymid.Present))
                             {
                                 pRasPymid.Create();//创建金字塔
                             }
                         }
                         IRaster      pRaster      = pRasterDataset.CreateDefaultRaster();
                         IRasterLayer pRasterLayer = new RasterLayer();
                         pRasterLayer.CreateFromRaster(pRaster);
                         ILayer pLayer = pRasterLayer as ILayer;
                         axmapcontrol.AddLayer(pLayer, 0);
                     }
                 }
             }
             else
             {
                 MessageBox.Show("重采样操作失败");
             }
         }
         else
         {
             MessageBox.Show("未选择需要保存的数据路径");
         }
     }
     else
     {
         MessageBox.Show("未选择需要重采样的栅格数据");
     }
 }
Ejemplo n.º 20
0
        private void buttonX_ok_Click(object sender, EventArgs e)
        {
            if (cmbTargetRasterLayer.SelectedItem != null)
            {
                m_DEMPath = cmbTargetRasterLayer.SelectedItem.ToString();
            }
            else
            {
                MessageBox.Show("请选择原始数据", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (m_ResultPath == null)
            {
                MessageBox.Show("请选择输出路径及文件名", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            RasterLayerClass rasterlayer = new RasterLayerClass();

            rasterlayer.CreateFromFilePath(m_DEMPath);
            IRaster       iRaster        = rasterlayer.Raster;
            int           i              = cmbOutType.SelectedIndex;
            IRaster       pRaster        = new Raster();
            IRasterLayer  pRasterLayer   = new RasterLayer();
            IFeatureLayer pFContourLayer = new FeatureLayerClass();

            switch (i)
            {
            case 0:
                pRaster = CreateRasterSlope(iRaster);
                if (pRaster == null)
                {
                    return;
                }
                pRasterLayer.CreateFromRaster(pRaster);
                pRasterLayer.Name = "坡度图";
                m_mapControl.AddLayer(pRasterLayer as ILayer);
                m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                break;

            case 1:
                pRaster = CreateRasterAspect(iRaster);
                if (pRaster == null)
                {
                    return;
                }
                pRasterLayer.CreateFromRaster(pRaster);
                pRasterLayer.Name = "坡向图";
                m_mapControl.AddLayer(pRasterLayer as ILayer);
                m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                break;

            case 2:
                pRaster = CreateRasterHillShade(iRaster);
                if (pRaster == null)
                {
                    return;
                }
                pRasterLayer.CreateFromRaster(pRaster);
                pRasterLayer.Name = "山体阴影图";
                m_mapControl.AddLayer(pRasterLayer as ILayer);
                m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                break;

            case 3:
                pFContourLayer = CreateRasterContour(iRaster);
                if (pFContourLayer == null)
                {
                    return;
                }
                pFContourLayer.Name = "等高线";
                m_mapControl.AddLayer(pFContourLayer as ILayer);
                m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                break;

            default:
                break;
            }
            //this.Close();
            return;
        }
Ejemplo n.º 21
0
        private void button3_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.DataManagementTools.Clip clp = new Clip();
            clp.in_raster  = getlayer(comboBox1.Text.ToString());
            clp.out_raster = textBoxsave.Text;
            if (checkBox1.Checked == true)
            {
                IGPUtilities gputilities = new GPUtilitiesClass();
                IEnvelope    penvelope   = 遥感数据管理系统.Form1.envelope.penv;
                clp.rectangle = string.Format("{0} {1} {2} {3} ", penvelope.XMin, penvelope.YMin, penvelope.XMax, penvelope.YMax);
            }
            else
            {
                IGPUtilities gputilities = new GPUtilitiesClass();
                IGeoDataset  pgeodataset = gputilities.OpenRasterDatasetFromString(getlayer(comboBox2.Text.ToString())) as IGeoDataset;
                IEnvelope    penvelope   = pgeodataset.Extent;
                clp.in_template_dataset = getlayer(comboBox2.Text.ToString());
                clp.rectangle           = string.Format("{0} {1} {2} {3} ", penvelope.XMin, penvelope.YMin, penvelope.XMax, penvelope.YMax);
            }
            clp.clipping_geometry = "true";
            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            IGeoProcessorResult gpresult = gp.Execute(clp, null) as IGeoProcessorResult;

            if (gpresult.Status == esriJobStatus.esriJobSucceeded)
            {
                DialogResult dl = MessageBox.Show("裁剪成功");
                if (dl == DialogResult.OK)
                {
                    if (checkBox3.Checked == true)
                    {
                        string fileFullName = textBoxsave.Text;
                        if (fileFullName == "")
                        {
                            return;
                        }
                        string            filePathName      = System.IO.Path.GetDirectoryName(fileFullName);
                        string            fileName          = System.IO.Path.GetFileName(fileFullName);
                        IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();                    //创建工作空间工厂
                        IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(filePathName, 0); //打开工作空间
                        IRasterWorkspace  pRasterWorkspace  = pWorkspace as IRasterWorkspace;                  //创建栅格工作空间
                        IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(fileName);    //创建Dataset
                        //影像金字塔创建与判断
                        IRasterPyramid2 pRasPymid = pRasterDataset as IRasterPyramid2;
                        if (pRasPymid != null)
                        {
                            if (!(pRasPymid.Present))
                            {
                                pRasPymid.Create();//创建金字塔
                            }
                        }
                        IRaster      pRaster      = pRasterDataset.CreateDefaultRaster();
                        IRasterLayer pRasterLayer = new RasterLayer();
                        pRasterLayer.CreateFromRaster(pRaster);
                        ILayer pLayer = pRasterLayer as ILayer;
                        axmapcontrol.AddLayer(pLayer, 0);
                    }
                }
            }
            else
            {
                MessageBox.Show("裁剪失败");
            }
        }