Ok, I played with the code you sent me: 1>You are doing a strange thing here. You are creating a BufferedImage to feed it to a Coverage, then you are reprojecting it, which by the way creates a new RenderedImage having as a source the original BufferedImage. Then you try to draw this reproject image onto the first one. I see that you might want to do some god memory reusing by reusing the first one but it might be a bit risky to overwrite the source image. You are basically creating reprojected image B from original image A (which btw is BufferedImage, hence it is all in memory untiled) where B is a tiled PlanarImage using a deferred model which causes computation only on demand. Then you are drawing image B back onto A. You like to risk huh? :-)
In some cases this should cause a lot of pains, especially with operations that needs more than one source tile to compute an output tile (high order interpolation is involved or convolutions). Anyway let's try the code... 2>I adapted a bit the code as shown below (copy and paste in an editor if you see it jaggled): public void test() throws FactoryException, IOException { // // // // Here below you have how to correctly create an envelope for a // coverage. // // // // final GeneralEnvelope sourceEnvelope = new GeneralEnvelope( // new double[] { -180, -90 }, new double[] { 180, 90 }); // sourceEnvelope.setCoordinateReferenceSystem(CRS.decode("EPSG:4326", // true)); // get a reader for the image final WorldImageReader wiReader = new WorldImageReader(new File( "D:\\data\\ikonos_rgb\\ikonos_rgb.tif")); // get the coverage GridCoverage2D coverage = (GridCoverage2D) wiReader.read(null); // now that we have the input image let's try to mess it up writing onto // a new bufferedimage with a strange color model final BufferedImage bi = new BufferedImage(coverage.getGridGeometry() .getGridRange().getLength(0), coverage.getGridGeometry() .getGridRange().getLength(1), BufferedImage.TYPE_INT_BGR); ((Graphics2D) bi.getGraphics()) .drawRenderedImage(coverage.getRenderedImage(), AffineTransform .getTranslateInstance(0, 0)); coverage = FactoryFinder.getGridCoverageFactory(null).create( "I_need_a_long_vacation", bi, coverage.getEnvelope()); // resample the created coverage coverage = (GridCoverage2D) Operations.DEFAULT.resample(coverage, CRS.decode("EPSG:32633")); final RenderedImage resampled =coverage.getRenderedImage(); // Painting some other BufferedImages PNG or JPEGS on the Canvas of // by using // the bi.getGraphics().drawImage(Image,..) Method ((Graphics2D) bi.getGraphics()).drawRenderedImage(resampled, AffineTransform.getTranslateInstance(0, 0)); // write it down ImageIO.write(bi, "tiff", new File("d:\\data\\b.tif")); } Surprise, surpise it works perfectly for me! This is funny (at least for me :-) for you I bet is annoying!). Let's try to ddig a bit more. I need to know: platform, geotools version, JAI version (do you have native libs installed?). Could you try to avoid drawing on the source image? I rather create a sibling one. Talk to you soon. Simone. PS: Not to soon, the elba island is waiting for me, I won't be back until tuesday 28th of august! On 8/23/07, Jody Garnett <[EMAIL PROTECTED]> wrote: > Thanks Martin/Tim I have updated the wiki with this description of resample: > - http://docs.codehaus.org/display/GEOTDOC/05+Resample+Operation > > I also added this question to the referencing FAQ: > - http://docs.codehaus.org/display/GEOTDOC/11+Referencing+FAQ > > Cheers, > Jody > > Martin Desruisseaux wrote: > > Tim Englich a écrit : > > > >>> I am looking for a possibility to transform an georefrenced image to an > >>> other coordinatereferencesystem. > >>> E.g. from EPSG:4326 to EPSG:32632 > >>> Provide GeoTools such a functionality? Do anyone know a (Java)-library > >>> which can do that. > >>> > > > > CoordinateReference sourceCRS = CRS.decode("EPSG:4326"); > > CoordinateReference targetCRS = CRS.decode("EPSG:32632"); > > RenderedImage image = ... > > Envelope imageEnvelope = ... > > imageEnvelope.setCoordinateReferenceSystem(sourceCRS); > > GridCoverage2D coverage = coverageFactory.create("My coverage", image, > > envelope); > > coverage = Operations.DEFAULT.resample(coverage, targetCRS); > > > > > > Martin > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Geotools-gt2-users mailing list > > Geotools-gt2-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- ------------------------------------------------------- Eng. Simone Giannecchini President /CEO GeoSolutions S.A.S. Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob: +39 333 8128928 http://www.geo-solutions.it ------------------------------------------------------- ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users