BUG
Pixel blocks must be populated by value and not by reference or the process will fail.
This is a known issue.
Code:
IRasterDataset rasDS = rasWksp2.createRasterDataset(aFile, "GRID", point, 200, 100, 1, 1, 1, rstPixelType.PT_FLOAT, sr, true);
Note:
The RasterDataset object represents a dataset on disk or in a database. The dataset provides access only to operations that apply to the entire dataset, with the RasterBand providing access to operations that occur on individual bands.
Code:
IRasterBandCollection bands = new IRasterBandCollectionProxy(rasDS);
IRasterBand band = bands.item(0);
Code:
IPnt size = new DblPnt();
IRawPixels rawPix = new IRawPixelsProxy(band);
IPixelBlock pixelBlk = rawPix.createPixelBlock(size);
IPnt pnt = new DblPnt();
pnt.setCoords(0, 0);
IRasterProps rasProps = new IRasterPropsProxy(rawPix);
size.setCoords(rasProps.getWidth(), rasProps.getHeight());
/*read pixelblock*/
rawPix.read(pnt, pixelBlk);
IPixelBlock3 pixelBlock = new IPixelBlock3Proxy(pixelBlk);
float[][] pixelData = (float[][])pixelBlock.getPixelData(0);
/*loop through all the pixels and assign value*/
for(int i = 0; i < (rasProps.getWidth() - 1); i++){
for(int j = 0; j < (rasProps.getHeight() - 1); j++){
pixelData[i][j] = (float)((i * j) % 255);
}
}
pixelBlock.setPixelData(0,pixelData);
Code:
IPixelBlock pblock = new IPixelBlockProxy(pixelBlock);
rawPix.write(pnt, pblock);
Code:
com.linar.jintegra.Cleaner.release(rawPix);
com.linar.jintegra.Cleaner.release(rasProps);
com.linar.jintegra.Cleaner.release(band);
com.linar.jintegra.Cleaner.release(bands);
com.linar.jintegra.Cleaner.release(rasDS);
return rasDS;
Article ID:000007736
Get help from ArcGIS experts
Download the Esri Support App