关闭

ArcGISEngine实现栅格数据裁剪

标签: ArcGISesri
1626人阅读 评论(0) 收藏 举报
分类:

ArcGIS空间分析扩展模块提供了对栅格数据进行裁剪抽取操作的功能,在ArcGISEngine中可以调用相关的GP工具来对栅格数据操作。

  •  调用空间分析ArcToolbox中Extract     By Polygon工具

privatevoid ExtractByPolygon()

        {

            IVariantArray parameters = newVarArrayClass();

            string sDocPath = @"C:\filerastergdb.gdb\raster";      //地图文档路径

            string sDocPath1 = @"C:\filerasteroutput.gdb\outraster";

           parameters.Add(sDocPath);

           

            string ss1 = "'545160.9444639276.889';'545216.242 4639266.57';'545227.355 4639308.375'";;

           parameters.Add(ss1);

           parameters.Add(sDocPath1);

           parameters.Add("INSIDE");

            IGeoProcessor2 gp = newGeoProcessorClass();

           gp.OverwriteOutput = true;

            IGeoProcessorResult pResult = null;

            try

            {

                pResult =gp.Execute("ExtractByPolygon", parameters, null);

                IWorkspaceFactory pFWSF = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();

               ESRI.ArcGIS.Geodatabase.IWorkspace pWS = pFWSF.OpenFromFile(@"C:\filerasteroutput.gdb", 0) ;

               ESRI.ArcGIS.Geodatabase.IRasterWorkspaceEx pRasterWs = pWS asESRI.ArcGIS.Geodatabase.IRasterWorkspaceEx;

                IRasterDataset pRasterDataset =pRasterWs.OpenRasterDataset("outraster");

                IRasterLayer pRasterLayer = newRasterLayerClass();

               pRasterLayer.CreateFromDataset(pRasterDataset);

                axMapControl1.AddLayer(pRasterLayer);

                string mess = null;

                for (int k = 0; k < gp.MessageCount; k++)

                {

                    mess+= gp.GetMessage(k) + "\n";

                }

                MessageBox.Show(mess);

            }

            catch (Exception err)

            {

                string msg = err.Message;

                string mess = null;

                for (int k = 0; k < gp.MessageCount; k++)

                {

                    mess+= gp.GetMessage(k) + "\n";

                }

                MessageBox.Show(mess);

            }

        }

 

  • 调用IExtractionOp接口对栅格数据裁剪

        publicvoid ExtractionRasterData(IGeoDataset pGeoDataset, ESRI.ArcGIS.Geometry.IPolygon pPolygone, bool binside)

        {

           ESRI.ArcGIS.SpatialAnalyst.IExtractionOp pExtractionOp = new ESRI.ArcGIS.SpatialAnalyst.RasterExtractionOpClass();

           ESRI.ArcGIS.Geodatabase.IGeoDataset pGeoOutput = pExtractionOp.Polygon(pGeoDataset, pPolygone,binside);

        }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:419192次
    • 积分:7014
    • 等级:
    • 排名:第3477名
    • 原创:292篇
    • 转载:3篇
    • 译文:1篇
    • 评论:36条
    最新评论