Hi Landon,
you talked with Simone :)
On Wed, May 13, 2009 at 5:18 PM, Sunburned Surveyor <
[email protected]> wrote:
> Someone on the OSGeo discuss list pointed out that Geotools has
> support for ECW images in a round-about way. I have been taking a look
> at the Javadoc and had a question or two.
>
> - I see that I can use the ECWReader to obtain a GridCoverage2D
> object. I didn't see a way to immediately pass a GridCoverage2D object
> to an object that would let me write a TIFF image or a JPEG. Is this
> possible? Or do I need to first obtain a RenderedImage?
> - If I can't write a GridCoverage2D object directly to TIFF or JPEG,
> are there any suggestions on how I would write a RenderedImage to one
> of these formats?
GridCoverageWriters (as an instance, GeoTIFFWriter and WorldImageWriter)
allow you to directly write a GridCoverage.
Anyway, in case you want to use imageio writers (TIFFImageWriter,
JPEGImageWriter,..) the GridCoverage2D class has a getRenderedImage method
which provide you a RenderedImage.
See belove for a simple quick test code writing:
1) a GridCoverage to a GeoTIFF
2) a RenderedImage to a JPEG a image .
>
> - Can Geotools be used to write ECW images? I didn't see a write class.
Actually not.
Writing example:
---------------------------------------------
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverageio.gdal.ecw.ECWFormat;
import org.geotools.gce.geotiff.GeoTiffFormat;
import org.opengis.coverage.grid.GridCoverageReader;
import org.opengis.coverage.grid.GridCoverageWriter;
import com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi;
public class GeoTiffWriteTest {
private static void writeGridCoverage() throws IllegalArgumentException,
IOException{
final File file = new File("c:/test.ecw");
final File filetiff = new File("c:/test.tiff");
final ECWFormat ecwformat = new ECWFormat();
final GeoTiffFormat tiffformat = new GeoTiffFormat();
// getting a reader
final GridCoverageReader reader = ecwformat.getReader(file);
final GridCoverage2D gc = (GridCoverage2D) reader.read(null);
final GridCoverageWriter writer = tiffformat.getWriter(filetiff);
writer.write(gc, null);
writer.dispose();
}
private static void writeRenderedImage() throws IOException{
final File file = new File("c:/test.ecw");
final File outputFile = new File("c:/test.jpg");
final ImageOutputStream ostream =
ImageIO.createImageOutputStream(outputFile);
final ECWFormat ecwformat = new ECWFormat();
// getting a reader
final GridCoverageReader reader = ecwformat.getReader(file);
final GridCoverage2D gc = (GridCoverage2D) reader.read(null);
final ImageWriter writer = new
JPEGImageWriterSpi().createWriterInstance();
writer.setOutput(ostream);
writer.write(gc.getRenderedImage());
ostream.flush();
ostream.close();
writer.dispose();
}
public static void main(String[] args) throws IllegalArgumentException,
IOException{
writeGridCoverage();
writeRenderedImage();
}
}
Regards,
Daniele
>
>
> Once again, it appears as if the Geotools programmers have already
> boldly gone where I need to go. Thanks for all of the hard work and
> patience with my questions.
>
> Landon
>
>
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK
> i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> Geotools-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
--
-------------------------------------------------------
Eng. Daniele Romagnoli
Software Engineer
GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy
phone: +39 0584983027
fax: +39 0584983027
mob: +39 328 0559267
http://www.geo-solutions.it
-------------------------------------------------------
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel