This article mainly introduces the use of IRawPixels interface to traverse raster data. It has a very good reference value. Let’s take a look at it with the editor.
The version of AO is 10.2, and the development language is C#. The raster data source is the IRasterDataset interface.
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); } }
The above is the content of the C# code example for traversing raster data using the IRawPixels interface. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!