On 29 July 2011 10:33, Marcos Nino-Ruiz <[email protected]> wrote: > Hi dear everyone, especially Michael Bedward,
Oh-oh... I always fear bad news when my name is mentioned up front. > I´m trying to build upon your > org.geotools.demo.coverage.WritableGridDemo.java example, because I > need to create my own Arc Grid Coverage. Don't expect production quality code with that one. If I remember rightly, it was a quick hack in response to a question on the list a couple of years ago. > I want to modify the values > of the raster and then save them in an ArcGrid coverage. The problem > is, if I want to have a more realistic coverage, with X and Y > dimensions different (not a square) when I go to save that coverage, > using : > // writableCov.show(); > String coveragePath= "covargeResult.asc"; > File outasc = new File(lsaResult); > if (outasc.exists()) > outasc.delete(); > ArcGridWriter agw; > agw = new ArcGridWriter(outasc); > agw.write(writableCov, null); > > It will show the following exception: > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 > at > com.sun.media.jai.iterator.WritableRandomIterFallback.makeCurrentWritable(WritableRandomIterFallback.java:33) > at > com.sun.media.jai.iterator.WritableRandomIterFallback.setSample(WritableRandomIterFallback.java:59) > at > edu.unimelb.climatechange.lsa.WritableGridCoverage2D.flushCache(WritableGridCoverage2D.java:240) > at > edu.unimelb.climatechange.lsa.WritableGridCoverage2D.getRenderedImage(WritableGridCoverage2D.java:135) > at > org.geotools.gce.arcgrid.ArcGridWriter.writeGridCoverage(ArcGridWriter.java:250) > at org.geotools.gce.arcgrid.ArcGridWriter.write(ArcGridWriter.java:506) Right - so the problem seems to be that the JAI iterator used to write the value to the image has been pointed to an invalid image location. But the flushCache method is deferring to the super class to convert world to grid (image) coordinates. So perhaps the problem goes back to when you are setting up the GridCoverage2D object that you subsequently pass to the WritableGridCoverage constructor. Could you post a snippet for how you are doing that please ? Michael ------------------------------------------------------------------------------ Got Input? Slashdot Needs You. Take our quick survey online. Come on, we don't ask for help often. Plus, you'll get a chance to win $100 to spend on ThinkGeek. http://p.sf.net/sfu/slashdot-survey _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
