[geotk] Looking for Java APIs to create a PNG from a double[][]
Robert Nix
robert at urban4m.com
Wed Oct 17 07:51:32 PDT 2012
Hi,
As a newbie to GIS, i'm looking for information on how to use GeoTools (or any appropriate) APIs to convert a double[][] into a PNG.
According to the manual technique using AWT i was trying (below), it seems i need a raster then saving it as a PNG but i'm hoping there's a more straightforward way using GeoTools APIs (and APIS that actually work for me :)
BTW, as i understand it, i'm generating tiles to be served (layered?) by GeoServer. If there's a better method/format, i'm open to that.
Thanks for any pointers you can provide,
Robert
DataBufferDouble db = new DataBufferDouble(d, d[0].length);
SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_DOUBLE,
w, h, 4, w * 4, new int[]{2, 1, 0, 3});
ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(
ColorSpace.CS_LINEAR_RGB), true, true, ColorModel.TRANSLUCENT,
DataBuffer.TYPE_DOUBLE);
WritableRaster wr = WritableRaster.createWritableRaster(sm, db, null);
BufferedImage bi = new BufferedImage(cm, wr, true, new Hashtable<>());
File outputfile = new File("saved.png");
ImageIO.write(bi, "png", outputfile);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20121017/63fd92ec/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1437 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20121017/63fd92ec/attachment.bin>
More information about the Geotoolkit
mailing list