I have noticed myself that JAI ImageWriter are a bit inefficient in termis of memory usage.
However, we would need to know a bit more about what you are doing before actually helping you out more and this one, specifically: -structure of the input data -java version -java memory used at start up (-Xmxvalue) Simone. ------------------------------------------------------- Ing. Simone Giannecchini GeoSolutions S.A.S. Owner - Software Engineer Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob: +39 333 8128928 http://www.geo-solutions.it http://simboss.blogspot.com/ http://www.linkedin.com/in/simonegiannecchini ------------------------------------------------------- On Thu, Feb 19, 2009 at 4:52 PM, Agossa <[email protected]> wrote: > > Thanks Michael, > > I have already try some JAI Descriptors but the point is that I cannot write > the resulting coverage in a tif file because I always receive Java heap > space exception(see below). Perhaps I need to provide some parameters to > avoid such an exception. > > Regards. > > Agossa. > > --------------------- > > RenderedImage img1 = cov1.getRenderedImage(); > RenderedImage img2 = cov2.getRenderedImage(); > RenderedImage result = MultiplyDescriptor.create(img1, img2, null); > GridCoverageFactory gcf=new GridCoverageFactory(); > cov2 = gcf.create("dd", result, > cov2.getEnvelope(),cov2.getSampleDimensions(),null,null); > > GeoTiffWriter geotiffw=null; > try { > geotiffw= new GeoTiffWriter(new > File("d:/data/try.tif")); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > geotiffw.write(cov2, null); > > > ------------------- > > > > > > > > > Exception in thread "main" java.lang.OutOfMemoryError: Java heap space > at java.lang.AbstractStringBuilder.<init>(Unknown Source) > at java.lang.StringBuffer.<init>(Unknown Source) > at > com.sun.media.imageioimpl.plugins.tiff.TIFFFieldNode.initialize(TIFFFieldNode.java:165) > at > com.sun.media.imageioimpl.plugins.tiff.TIFFFieldNode.getLength(TIFFFieldNode.java:205) > at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:276) > at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:280) > at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:280) > at org.jdom.input.DOMBuilder.build(DOMBuilder.java:147) > at > org.geotools.gce.geotiff.GeoTiffWriter.createGeoTiffIIOMetadata(GeoTiffWriter.java:436) > at > org.geotools.gce.geotiff.GeoTiffWriter.writeImage(GeoTiffWriter.java:384) > at org.geotools.gce.geotiff.GeoTiffWriter.write(GeoTiffWriter.java:225) > > > > > Michael Bedward wrote: >> >> No - that hasn't been included in the OperationJAI classes. The >> easiest way for you to do it is to use JAI directly. >> >> For example, assuming that your two grid coverages have the same >> bounds here is one was of doing it... >> >> import javax.media.jai.operator.MultiplyDescriptor; >> >> RenderedImage img1 = cov1.getRenderedImage(); >> RenderedImage img2 = cov2.getRenderedImage(); >> RenderedImage result = MultiplyDescriptor.create(img1, img2, null); >> >> Then you can use GridCoverageFactory to create a coverage from the result >> image >> http://javadoc.geotools.fr/2.5/org/geotools/coverage/grid/GridCoverageFactory.html >> >> Hope this helps >> >> Michael >> >> ------------------------------------------------------------------------------ >> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, >> CA >> -OSBC tackles the biggest issue in open source: Open Sourcing the >> Enterprise >> -Strategies to boost innovation and cut costs with open source >> participation >> -Receive a $600 discount off the registration fee with the source code: >> SFAD >> http://p.sf.net/sfu/XcvMzF8H >> _______________________________________________ >> Geotools-gt2-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> >> > > -- > View this message in context: > http://n2.nabble.com/Making-an-Operation-with-two-GridCoverages-as-operand--in-Geotools-tp2347456p2353660.html > Sent from the geotools-gt2-users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
