zoukankan      html  css  js  c++  java
  • ArcEngine 实现SurfaceAnalysis中的Cut/Fill功能

     /// <summary>
            /// 计算两个表面之间的体积
            /// </summary>
            /// <param name="usfolder">上表面父目录</param>
            /// <param name="usdataset">上表面目录名</param>
            /// <param name="dsfolder">下表面父目录</param>
            /// <param name="dsdataset">下表面目录名</param>
            public void CalculateCutFill(string usfolder,string usdataset,string dsfolder,string dsdataset)
            {
                //设置CutFill分析时的cellSize
    
    
                /*object cellsize = 0.345;
                RasterSurfaceOpClass rclass = new RasterSurfaceOpClass();
                rclass.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellsize);
                ISurfaceOp psurfaceOp = rclass;*/
    
             /* ITin pTinUp = GetTinLayer(usfolder, usdataset);
                ITin pTinDown = GetTinLayer(dsfolder, dsdataset);
                IGeoDataset pGeodsUp = pTinUp as IGeoDataset;       //在ArcMap中可以用Tin直接进行CutFill.但是Engine中,只能用Raster作为ISurfaceOp.CutFill的参数
                IGeoDataset pGeodsDown = pTinDown as IGeoDataset;*/ //若使用ITin转成GeodataSet作为参数,提示InvalidInputGeodataset
                                                                    //处理方式:先用3DAnalysis的TinToRaster,将两个Tin转成Raster
    
                ISurfaceOp psurfaceOp = new RasterSurfaceOpClass();
                IGeoDataset pGeodsUp = OpenRasterDataSet(@"E:\ShpForContour\ContourFromShp", "tin2529raster") as IGeoDataset;//ISurfaceOp.CutFill(geods,geods,obj)
                IGeoDataset pGeodsDown = OpenRasterDataSet(@"E:\ShpForContour\ContourFromShp", "tinbottomrar") as IGeoDataset;//geods要求是rasterdataset, Tindataset不行
                
                object zfactor=new object();
                zfactor = 1.0;
                IGeoDataset pGeodsResult = psurfaceOp.CutFill(pGeodsUp, pGeodsDown, ref zfactor);//CutFill分析
                
                //读取Raster的属性表
                IRaster pRaseter = pGeodsResult as IRaster; //IGeoDataset转IRaster
                IRasterBandCollection pRasterBC = pRaseter as IRasterBandCollection;
                IRasterBand pRasterBand = pRasterBC.Item(0);
                ITable pTable = pRasterBand.AttributeTable;
    
                ICursor pCursor = pTable.Search(null, false);
                IRow pRow = pCursor.NextRow();
    
    
                DataTable dt = new DataTable();
                 
    
                for (int i = 0; i < pTable.Fields.FieldCount; i++)
                {
                    dt.Columns.Add(pTable.Fields.get_Field(i).Name);
                    //MessageBox.Show(pTable.Fields.get_Field(i).Name);    //字段名字
                }
    
                while (pRow != null)
                {
                    //以下显示COUNT字段的值
                    DataRow dr = dt.NewRow();
                    for (int i = 0; i <= dt.Columns.Count - 1; i++)
                    {
                        dr[i] = Convert.ToString(pRow.get_Value(i));
                    }
                    dt.Rows.Add(dr);
                    pRow = pCursor.NextRow();
                }
            }
     

     备注:

        在ArcMap中SurfaceAnalysis CutFill分析的结果只能存为可以是ESRI GRID(Raster),TIFF,ERDAS 三种类型。这三种类型都是栅格数据

  • 相关阅读:
    Flink入门(一)——Apache Flink介绍
    ES入门宝典(详细截图版)
    什么是全文检索
    Hbase入门(五)——客户端(Java,Shell,Thrift,Rest,MR,WebUI)
    Hbase入门(四)——表结构设计-RowKey
    Hbase入门(三)——数据模型
    Hbase入门(二)——安装与配置
    Hbase入门(一)——初识Hbase
    Flink1.9整合Kafka
    ShutdownHook
  • 原文地址:https://www.cnblogs.com/imihiroblog/p/2455556.html
Copyright © 2011-2022 走看看