• ArcGISEngine实现栅格数据裁剪


    ArcGISEngine实现栅格数据裁剪

    上一篇 / 下一篇  2012-12-27 00:09:47 / 个人分类:ArcGISEngine开发

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

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

    private void ExtractByPolygon()

            {

                IVariantArray parameters = new VarArrayClass();

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

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

                parameters.Add(sDocPath);

               

                string ss1 = "'545160.944 4639276.889';'545216.242 4639266.57';'545227.355 4639308.375'";;

                parameters.Add(ss1);

                parameters.Add(sDocPath1);

                parameters.Add("INSIDE");

                IGeoProcessor2 gp = new GeoProcessorClass();

                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 as ESRI.ArcGIS.Geodatabase.IRasterWorkspaceEx;

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

                    IRasterLayer pRasterLayer = new RasterLayerClass();

                    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接口对栅格数据裁剪

            public void 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);

            }

  • 相关阅读:
    几个计算广告学的课程
    Jie Bao 牛人cv
    如果英剧《黑镜子》拍第三季,你来写一集剧本策划,你想写一个什么样的故事呢? 知乎
    设计模式之迭代器与组合模式
    javascript 时钟clock
    项目中的需求蔓延
    一个产生随机random markers 例子
    设计模式之模板方法模式
    设计模式之反(向)模式
    转:用函数式编程技术编写优美的 JavaScript
  • 原文地址:https://www.cnblogs.com/xianyin05/p/3100949.html
Copyright © 2020-2023  润新知