加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C# 利用IRawPixels接口遍历栅格数据

发布时间:2020-12-15 07:39:42 所属栏目:百科 来源:网络整理
导读:AO的版本为10.2,开发的语言是C#。栅格数据来源IRasterDataset接口。 IRasterBandCollection pRasterBandCollection = pRasterDataset as IRasterBandCollection;IRasterBand pRasterBand = pRasterBandCollection.Item(0); IRaster pRaster = (pRasterDatas

AO的版本为10.2,开发的语言是C#。栅格数据来源IRasterDataset接口。

IRasterBandCollection pRasterBandCollection = pRasterDataset as IRasterBandCollection;
IRasterBand pRasterBand = pRasterBandCollection.Item(0);
 IRaster pRaster = (pRasterDataset as IRasterDataset2).CreateFullRaster();
IRawPixels pRawPixels = pRasterBand as IRawPixels;
IRasterProps pRasterProps = pRasterBand as IRasterProps;
int dHeight = pRasterProps.Height;
int dWidth = pRasterProps.Width; 
IPnt pntSize = new PntClass();
pntSize.SetCoords(dHeight,dWidth);
IPnt pPixelBlockOrigin = new PntClass();
pPixelBlockOrigin.SetCoords(0,0);
IPixelBlock pixelBlock = pRaster.CreatePixelBlock(pntSize);
pRawPixels.Read(pPixelBlockOrigin,pixelBlock);
System.Array arr = (System.Array)(pixelBlock as IPixelBlock3).get_PixelData(0);
for (int i = 0; i < dHeight;i++ ) 
{
 for (int j = 0; j < dWidth; j++) 
 {
   float number = 0;
   float.TryParse(arr.GetValue(i,j).ToString(),out number);     
  }
}

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持编程小技巧!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读