JAVA Raster: Writing to a pixel block

908
2
12-30-2012 10:28 AM
AvishekDutta
New Contributor
Hi,

Can someone please help with the Java code to write values into a pixel block!?

IRasterDataset streamOrder  = rasterWorkSpace.openRasterDataset("streamOrder.tif");
RasterDataset streamOrderRas = (RasterDataset)streamOrder;

RasterBand streamOrderBand = new RasterBand(streamOrderRas.item(0));

IPnt size1 = new DblPnt();
size1.setCoords(streamOrderBand.getWidth(), streamOrderBand.getHeight());

PixelBlock writePixBlock = (PixelBlock)(streamOrderBand.createPixelBlock(size1));
IPnt tlc1 = new DblPnt();
tlc1.setCoords(0, 0);
streamOrderBand.read(tlc1, writePixBlock);

Object vPixels = writePixBlock.getSafeArray(0);


I am not able to proceed further! I cannot cast this vPixels into anything, hence I am not able to access or alter the values inside.

Will changing the safe array and setting it to the pixel block be enough? I also tried IPixelBlock3 but it did not work.

Please can some one show a working example.

Thanks,
Avishek
0 Kudos
2 Replies
AvishekDutta
New Contributor
Is anybody out there?
0 Kudos
AvishekDutta
New Contributor
Hi,

I am trying to run the http://help.arcgis.com/en/sdk/10.0/java_ao_adf/conceptualhelp/engine/index.html#/How_to_create_a_ras...

But the values are not getting persisted to permanent storage. When I open the raster in ArcMap, I get a raster with
High : 2147483647 & Low : -2147483648.

Can anyone please explain this? I am running the code as it is!

Avi
0 Kudos