VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之利用IRawPixels接口遍历栅格数据

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

复制代码
 1  IRasterBandCollection pRasterBandCollection = pRasterDataset as IRasterBandCollection;
 2 IRasterBand pRasterBand = pRasterBandCollection.Item(0);
 3  IRaster pRaster = (pRasterDataset as IRasterDataset2).CreateFullRaster();
 4 IRawPixels pRawPixels = pRasterBand as IRawPixels;
 5 IRasterProps pRasterProps = pRasterBand as IRasterProps;
 6 int dHeight = pRasterProps.Height;
 7 int dWidth = pRasterProps.Width;  
 8 IPnt pntSize = new PntClass();
 9 pntSize.SetCoords(dHeight, dWidth);
10 IPnt pPixelBlockOrigin = new PntClass();
11 pPixelBlockOrigin.SetCoords(0, 0);
12 IPixelBlock pixelBlock = pRaster.CreatePixelBlock(pntSize);
13 pRawPixels.Read(pPixelBlockOrigin, pixelBlock);
14 System.Array arr = (System.Array)(pixelBlock as IPixelBlock3).get_PixelData(0);
15 for (int i = 0; i < dHeight;i++ ) 
16 {
17     for (int j = 0; j < dWidth; j++) 
18     {
19            float number = 0;
20            float.TryParse(arr.GetValue(i,j).ToString(),out number);                   
21      }
22 }
复制代码

第一次写,同时也做一个记录


相关教程