Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

double precision using IPixelBlock3 and setPixelData

$
0
0
Hi all

I'm trying to to write a double[][] array to a IPixelBlock3 instance using Java. Here is an abstract of my source.
Code:

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:
Code:

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(RasterWorkspaceWriter.java:94)
        at ILUMOE.LoopThroughMatrix.oneTimeStep(LoopThroughMatrix.java:177)
        at ILUMOE.ILUMOEControl.main(ILUMOEControl.java:77)

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

Viewing all articles
Browse latest Browse all 1374

Trending Articles