Ciao Jared,
I am sorry that I onl received this email now. The following code
snippet should do the trick. If ti does not work, pleas, let me know.


                        ////
                        //
                        // Pre-requisites
                        //
                        ////
                        GridCoverageFactory gcf = new GridCoverageFactory();
                        //you can use your image here
                        RenderedImage ri = JAI.create("ImageRead", new File(
                                        "c:/work/data/004.tiff"));
                        //original envelope goes here
                        DirectPosition2D llc = new DirectPosition2D(
                                        DefaultGeographicCRS.WGS84, -80, 50);
                        DirectPosition2D urc = new DirectPosition2D(
                                        DefaultGeographicCRS.WGS84, -70, 40);
                        
                        ////
                        //
                        //Creating georeferencing
                        //
                        ////
                        //final coordinate reference system.
                        CoordinateReferenceSystem finalCRS = 
CRS.decode("EPSG:4267",true);
                        MathTransform mt = CRS.findMathTransform(
                                        DefaultGeographicCRS.WGS84, finalCRS, 
true);
                        
                        //final envelope
                        GeneralEnvelope finalEnvelope = new GeneralEnvelope(2);
                        finalEnvelope.setCoordinateReferenceSystem(finalCRS);
                        finalEnvelope.add(mt.transform(llc, new 
DirectPosition2D()));
                        finalEnvelope.add(mt.transform(urc, new 
DirectPosition2D()));

                        ////
                        //
                        //Creating final coverage
                        //
                        ////
                        //creating final coverage
                        GridCoverage2D gc1 = gcf.create("test", ri, 
finalEnvelope);

                        //creating final geotiff file
                        File f = new File("c:/work/data/geotiff1.tif");
                        GeoTiffWriter gtw = new GeoTiffWriter(f);
                        gtw.write(gc1, null);



Hope that helps.
Simone.

On 1/9/07, Jared B Dorny <[EMAIL PROTECTED]> wrote:
>
> All,
>
> I have the following information:
>
> BufferedImage object ( Read in from a file using ImageIO)
> A Coordinate Reference System ID (in this case its EPSG:4267 but it could be
> any valid one)
> Coordinates of the lower left corner and upper right corner in Latitude,
> Longitude (WGS84 (EPSG:4326))
> Filename
>
> What I want to do is create a method that takes the information and then
> writes out a Geotif with the correct header information. With out modifying
> the raster portion.
>
>
> Here is where I am struggling. I can convert the coordinates to the
> requested projection using techniques specified in the demo class for
> converting between systems. Which gives me two DirectPosition2D objects one
> for the lower left corner and one for the upper right corner.
>
> I then don't know how to create a Envelope since the Envelope2D takes a
> Rectangle. Which is the lower left coordinate and the width and height.
>
> How do I create the Rectangle from the two DirecPosition2D objects? that is
> correct for any passed in targetCRS.
>
> Once I have the envelope I can then create the GridCoverage and then write
> it out. (I have done this already)
>
> The key here is that I know the corners in terms of Lat- Long and the image
> is in a known projection. I need to get the points into the images
> projection to correctly write to GeoTiff.
>
> Any Ideas?
>
> Thanks,
>
> Jared
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
>


-- 
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions

http://www.geo-solutions.it

-------------------------------------------------------

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to