<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JAVA Raster: Writing to a pixel block in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99872#M2656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone please help with the Java code to write values into a pixel block!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;IRasterDataset streamOrder&amp;nbsp; = 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);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Will changing the safe array and setting it to the pixel block be enough? I also tried IPixelBlock3 but it did not work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please can some one show a working example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Avishek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 30 Dec 2012 18:28:09 GMT</pubDate>
    <dc:creator>AvishekDutta</dc:creator>
    <dc:date>2012-12-30T18:28:09Z</dc:date>
    <item>
      <title>JAVA Raster: Writing to a pixel block</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99872#M2656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone please help with the Java code to write values into a pixel block!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;IRasterDataset streamOrder&amp;nbsp; = 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);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Will changing the safe array and setting it to the pixel block be enough? I also tried IPixelBlock3 but it did not work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please can some one show a working example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Avishek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Dec 2012 18:28:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99872#M2656</guid>
      <dc:creator>AvishekDutta</dc:creator>
      <dc:date>2012-12-30T18:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: JAVA Raster: Writing to a pixel block</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99873#M2657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is anybody out there?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2013 12:38:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99873#M2657</guid>
      <dc:creator>AvishekDutta</dc:creator>
      <dc:date>2013-01-03T12:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: JAVA Raster: Writing to a pixel block</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99874#M2658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to run the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/java_ao_adf/conceptualhelp/engine/index.html#/How_to_create_a_raster_dataset/0001000002p6000000/"&gt;http://help.arcgis.com/en/sdk/10.0/java_ao_adf/conceptualhelp/engine/index.html#/How_to_create_a_raster_dataset/0001000002p6000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the values are not getting persisted to permanent storage. When I open the raster in ArcMap, I get a raster with &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;High : 2147483647 &amp;amp; Low : -2147483648.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone please explain this? I am running the code as it is!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Avi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jan 2013 11:32:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-raster-writing-to-a-pixel-block/m-p/99874#M2658</guid>
      <dc:creator>AvishekDutta</dc:creator>
      <dc:date>2013-01-04T11:32:14Z</dc:date>
    </item>
  </channel>
</rss>

