Hi all, I'm not sure if this is a prob with the javadocs (possible), or the GridCoverage2D class (unlikely) or my understanding (very probably)...
I was trying to create a GC2D object from an array of double data as follows: DataBuffer buffer = new DataBufferDouble(data, data.length); SampleModel sample = new BandedSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1); WritableRaster raster = Raster.createWritableRaster(sample, buffer, null); Envelope2D envelope = new Envelope2D(crs, minX, minY, width, height); GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GridCoverage2D cov = factory.create(name, raster, envelope); This provokes a runtime exception about having the wrong ColorModel. So I changed the code to the following... ColorModel colorModel = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, ColorModel.TRANSLUCENT, DataBuffer.TYPE_DOUBLE); SampleModel model = new BandedSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1); DataBuffer buffer = new DataBufferDouble(data, data.length); WritableRaster raster = Raster.createWritableRaster(model, buffer, null); BufferedImage img = new BufferedImage(colorModel, raster, false, null); GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); Envelope2D envelope = new Envelope2D(crs, minX, minY, width, height); GridCoverage2D cov = factory.create(name, img, envelope); ...and all works fine. My question is: should the javadocs say that the factory create method used in the first version of my code does not work with double data ? Or is this a bug ? Or (more likely) have I missed something ? cheers Michael ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users