AO的版本為10.2,開發的語言是C#。柵格數據來源IRasterDataset介面。 第一次寫,同時也做一個記錄 ...
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 }
第一次寫,同時也做一個記錄