AnsweredAssumed Answered

double precision using IPixelBlock3 and setPixelData

Question asked by pasithee on Feb 27, 2013
Latest reply on Mar 8, 2013 by pasithee
Hi all

I'm trying to to write a double[][] array to a IPixelBlock3 instance using Java. Here is an abstract of my source.
IRasterWorkspace2 workspace = new IRasterWorkspace2Proxy(new RasterWorkspaceFactory().openFromFile(folder, 0)); try {     double[][] data = cache.get(key);      int height = data[0].length;      int width = data.length;       IUnknownCoordinateSystem sr = new UnknownCoordinateSystem();    IPoint origin = new Point();  origin.putCoords(12.5, 12.5);         IRasterDataset rasterDataset = workspace.createRasterDataset(filename, "GRID",           origin, width, height, 25, 25, 1, rstPixelType.PT_DOUBLE, sr,           true);         IRasterBandCollection rasterBands = new IRasterBandCollectionProxy(rasterDataset);      IRasterBand rasterBand;  IRasterProps rasterProps;  rasterBand = rasterBands.item(0);  rasterProps = new IRasterPropsProxy(rasterBand);          rasterProps.setNoDataValue(255);   IRaster raster = rasterDataset.createDefaultRaster();  IPnt blocksize = new Pnt();  blocksize.setCoords(width, height);  IPixelBlock3 pixelblock = new IPixelBlock3Proxy(raster.createPixelBlock      (blocksize));         pixelblock.setPixelData(0, data);    IPnt upperLeft = new Pnt();  upperLeft.setCoords(0, 0);   IRasterEdit rasterEdit = new IRasterEditProxy(raster);  rasterEdit.write(upperLeft, new IPixelBlockProxy(pixelblock));  Cleaner.release(rasterEdit);        } catch (UnknownHostException e) {  throw new IOException(e.getMessage()); } catch (IOException e) {  throw e; }

Using this code, I'm getting the following exception:
Exception in thread "main" AutomationException: 0x80070057 - This spatial reference object cannot be defined from the available information. in '"esri.ProjectedCoordinateSystem"'  at com.esri.arcgis.interop.NativeObjRef.nativeVtblInvokeNative(Native Method)  at com.esri.arcgis.interop.NativeObjRef.a(Unknown Source)  at com.esri.arcgis.interop.NativeObjRef.a(Unknown Source)  at com.esri.arcgis.interop.Dispatch.vtblInvoke(Unknown Source)  at com.esri.arcgis.datasourcesraster.IPixelBlock3Proxy.setPixelData(Unknown Source)  at ILUMOE.writer.RasterWorkspaceWriter.write(  at ILUMOE.LoopThroughMatrix.oneTimeStep(  at ILUMOE.ILUMOEControl.main(

If I change the double[][] to a int[][] and using the PT_UCHAR (8-bit integer) it works.

Does someone has any idea how to store double precision values / points?

Thanks a lot