<?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 Error of writing raster in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/error-of-writing-raster/m-p/81748#M2135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I am writing a raster editor toolbar for interactive raster edition. It is almost done but I meet an error when I try to save the modification to file finally. My method is to copy the loaded raster and write the modification to the new file. Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
// Code to get the new raster
IRasterWorkspace newRasterWorkspace = (IRasterWorkspace)newWorkspace;
IRasterDataset newRasterDataset = newRasterWorkspace.OpenRasterDataset(System.IO.Path.GetFileNameWithoutExtension(saveFileDialog.FileName));
IRasterBandCollection newRasterBandCollection = (IRasterBandCollection)newRasterDataset;
IRasterBand newRasterBand = newRasterBandCollection.Item(0);
IRasterDataset2 newRasterDataset2 = (IRasterDataset2)newRasterBand.RasterDataset;
IRaster newRaster = newRasterDataset2.CreateFullRaster();
IRasterProps newRasterProp = (IRasterProps)newRaster;

// I omit some code to get the extent of modified region

IPnt pos = new PntClass();
pos.SetCoords(maxCol - minCol + 1, maxRow - minRow + 1);
IPixelBlock pixelBlock = newRaster.CreatePixelBlock(pos);
pos.SetCoords(minCol, minRow);
newRaster.Read(pos, pixelBlock);

// Set new values
IPixelBlock3 pixelBlock3 = (IPixelBlock3)pixelBlock;
Array pixels = (Array)pixelBlock3.get_PixelData(0);


for (int i = 0; i &amp;lt; Editor.EditRecord.Count; i++)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; pixels.SetValue(Convert.ToByte(Editor.EditRecord&lt;I&gt;.NewValue),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Editor.EditRecord&lt;I&gt;.Position.Column - minCol,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Editor.EditRecord&lt;I&gt;.Position.Row - minRow);
}

pixelBlock3.set_PixelData(0, (System.Object)pixels);
IRasterEdit newRasterEdit = (IRasterEdit)newRaster;

// Here comes the error:
newRasterEdit.Write(pos, (IPixelBlock)pixelBlock3);
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the error information: Exception from HRESULT: 0x80041029. I do not find any information about the error code at ESRI help. The code looks very correct and I have no idea of the error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;btw, is there a way to directly save modification to the raster loaded at ArcMap?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Haoliang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jan 2014 01:58:45 GMT</pubDate>
    <dc:creator>HaoliangYu</dc:creator>
    <dc:date>2014-01-16T01:58:45Z</dc:date>
    <item>
      <title>Error of writing raster</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/error-of-writing-raster/m-p/81748#M2135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I am writing a raster editor toolbar for interactive raster edition. It is almost done but I meet an error when I try to save the modification to file finally. My method is to copy the loaded raster and write the modification to the new file. Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
// Code to get the new raster
IRasterWorkspace newRasterWorkspace = (IRasterWorkspace)newWorkspace;
IRasterDataset newRasterDataset = newRasterWorkspace.OpenRasterDataset(System.IO.Path.GetFileNameWithoutExtension(saveFileDialog.FileName));
IRasterBandCollection newRasterBandCollection = (IRasterBandCollection)newRasterDataset;
IRasterBand newRasterBand = newRasterBandCollection.Item(0);
IRasterDataset2 newRasterDataset2 = (IRasterDataset2)newRasterBand.RasterDataset;
IRaster newRaster = newRasterDataset2.CreateFullRaster();
IRasterProps newRasterProp = (IRasterProps)newRaster;

// I omit some code to get the extent of modified region

IPnt pos = new PntClass();
pos.SetCoords(maxCol - minCol + 1, maxRow - minRow + 1);
IPixelBlock pixelBlock = newRaster.CreatePixelBlock(pos);
pos.SetCoords(minCol, minRow);
newRaster.Read(pos, pixelBlock);

// Set new values
IPixelBlock3 pixelBlock3 = (IPixelBlock3)pixelBlock;
Array pixels = (Array)pixelBlock3.get_PixelData(0);


for (int i = 0; i &amp;lt; Editor.EditRecord.Count; i++)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; pixels.SetValue(Convert.ToByte(Editor.EditRecord&lt;I&gt;.NewValue),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Editor.EditRecord&lt;I&gt;.Position.Column - minCol,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Editor.EditRecord&lt;I&gt;.Position.Row - minRow);
}

pixelBlock3.set_PixelData(0, (System.Object)pixels);
IRasterEdit newRasterEdit = (IRasterEdit)newRaster;

// Here comes the error:
newRasterEdit.Write(pos, (IPixelBlock)pixelBlock3);
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the error information: Exception from HRESULT: 0x80041029. I do not find any information about the error code at ESRI help. The code looks very correct and I have no idea of the error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;btw, is there a way to directly save modification to the raster loaded at ArcMap?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Haoliang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 01:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/error-of-writing-raster/m-p/81748#M2135</guid>
      <dc:creator>HaoliangYu</dc:creator>
      <dc:date>2014-01-16T01:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error of writing raster</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/error-of-writing-raster/m-p/81749#M2136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have solved the problem by adding the following code in advance:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2014 18:03:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/error-of-writing-raster/m-p/81749#M2136</guid>
      <dc:creator>HaoliangYu</dc:creator>
      <dc:date>2014-01-20T18:03:47Z</dc:date>
    </item>
  </channel>
</rss>

