您的位置:首页 > 编程语言 > C#

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

2017-02-10 11:22 633 查看

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);
}
}

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  遍历 栅格