AnsweredAssumed Answered

Can't create Raster DataSet

Question asked by taibc on Oct 2, 2012
Latest reply on Oct 3, 2012 by taibc
Hi,

I am trying to create a Raster Dataset by using below codes, but I got an error: Error HRESULT E_FAIL has been returned from a call to a COM component.

            IRasterWorkspace2 ws = (IRasterWorkspace2)OpenRasterWorkspace(@"d:\data");
            IPoint origin = new PointClass();
            origin.PutCoords(100, 100);
            ISpatialReference sr = new UnknownCoordinateSystemClass();
            IRasterDataset newRaster = ws.CreateRasterDataset("myimage.img",
              "IMAGINE Image", origin, 1024, 1024, 30, 30, 1, rstPixelType.PT_UCHAR, sr,
              true);

IRasterWorkspace OpenRasterWorkspace(string filePath)
        {
            IWorkspaceFactory wsFactory = new RasterWorkspaceFactoryClass();
            IRasterWorkspace rasterWS = (IRasterWorkspace)wsFactory.OpenFromFile(filePath,
              0);
            return rasterWS;
        }

Do you know why ?

Thanks and regards,

Outcomes