3

I am trying to change the a raster's NoData value with ArcObjects and keep coming up short.

Here is the code that I thought would work:

IRasterDataset _dataset = ...get the dataset...
object[] noDataValue = ...set the no data values by raster band...
var rasterbandCollection = (IRasterBandCollection) _dataset;
for(int i = 0; i < rasterbandCollection.Count; i++)
{
 ((IRasterProps) rasterbandCollection.Item(i)).NoDataValue = noDataValue[i];
}

This value persists during the ArcMap session, but does not save the changes to disk it appears. Any ideas on how to make this permanent (without having to save a second raster dataset)?

asked Jun 7, 2012 at 14:50

2 Answers 2

2

If you read the Help on the IRasterProps Interface is says

These modifications only affect the in-memory raster representation and in no way change any of the raster dataset. You can persist the modifications to a new raster datast using ISaveAs::SaveAs or IRasterBandCollection::SaveAs

So you can't just change it without creating a new raster dataset.

answered Jun 7, 2012 at 19:57
1
  • I did read that and thought that was applying to a in memory instance (which I was hoping to get around by going with the raster band). That is probably the answer, was just wishing it wasn't. Commented Jun 7, 2012 at 21:37
0

if you set nodata in a rasterdataset store in disk you can change the nodata permanent

 rasterBandCollection = rasterDataset as IRasterBandCollection;
 rasterBand = rasterBandCollection.Item(0);
 rasterProps = rasterBand as IRasterProps;
 rasterProps.NoDataValue = -9999; 
answered Sep 14, 2015 at 13:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.