AnsweredAssumed Answered

CreateRasterDataset in Geodatabase

Question asked by gilest on Sep 30, 2013
Latest reply on Oct 1, 2013 by gilest
using C#, visual studio 2010, ArcGIS 10.1 -

I'm using the following code to create a new RasterDataset in a file geodb -

                //create                 IRasterWorkspaceEx rWS = (IRasterWorkspaceEx)ws;                 IRasterStorageDef2 rStorage = new RasterStorageDefClass();                 rStorage.CellSize = new Pnt(){X=cellsize,Y=cellsize};                 rStorage.Origin = origin;                 IRasterDef2 rDef = new RasterDefClass();                 rDef.SpatialReference = srOut;                 rds = (IRasterDataset2)rWS.CreateRasterDataset(strName, 1, ptype, rStorage, "", rDef, null);


This works, but the output RasterDataset is only 1 pixel big.  When you call CreateRasterData through IRasterWorkspace (for file based rasters) you can specify the width and height.  Basically I have a 2d array I'm trying to write into the raster - how do I do this when the output is only 1 pixel big?

I've tried casting to IRasterProps and changing the Width and Height props but that throws a COMException even though in the help they look to be read/write props -

                IRasterBandCollection rbc = (IRasterBandCollection)rds;                 IRasterProps rProps = (IRasterProps)rbc.Item(0);                 rProps.NoDataValue = nodataval;                 rProps.Width = Data.GetLength(0);  //Error here                 rProps.Height = Data.GetLength(1);


A push in the right direction would be appreciated!

Thanks, Terry

Outcomes