Hi!

I'm trying to plot a same geo point into two differents images, but the
regions don't match (see the following images). The images are displaying
the same Earth's region in differents envelopes and time, referenced using
DATUM SAD69. There're too a XML metadata about each image.

http://www.nabble.com/file/p20109846/imagem3.png 

See that the point in first image is over on the river and it's out in
second image.

Here, a snippet of the XMLs files:

    <datumName>SAD69</datumName>
    <semiMajorAxis>6378160.000000</semiMajorAxis>
    <flattening>0.003353</flattening>
    <xShiftToWGS84>-66.870000</xShiftToWGS84>
    <yShiftToWGS84>4.370000</yShiftToWGS84>
    <zShiftToWGS84>-38.520000</zShiftToWGS84>
    <projectionName>UTM</projectionName>
    <originLongitude>-60</originLongitude>                <=== This's the
only difference
    <originLatitude>0</originLatitude>
    <scaleFactor>0.999600</scaleFactor>
    <falseEasting>500000.000000</falseEasting>
    <falseNorthing>10000000.000000</falseNorthing>

    <datumName>SAD69</datumName>
    <semiMajorAxis>6378160.000000</semiMajorAxis>
    <flattening>0.003353</flattening>
    <xShiftToWGS84>-66.870000</xShiftToWGS84>
    <yShiftToWGS84>4.370000</yShiftToWGS84>
    <zShiftToWGS84>-38.520000</zShiftToWGS84>
    <projectionName>UTM</projectionName>
    <originLongitude>-57</originLongitude>                <=== This's the
only difference
    <originLatitude>0</originLatitude>
    <scaleFactor>0.999600</scaleFactor>
    <falseEasting>500000.000000</falseEasting>
    <falseNorthing>10000000.000000</falseNorthing>

Here a snippet of my code (using GeoTools 2.4.4):

        ...

        //Read the source images (these images are scaled in 10% of orignals
for speed improvement).
        File path0 = new File("images/20000905_BAND4.tif");
        File path1 = new File("images/20080927_BAND4.tif");
        GridCoverage2D src0 = (GridCoverage2D) (new
GeoTiffReader(path0)).read(null);
        GridCoverage2D src1 = (GridCoverage2D) (new
GeoTiffReader(path1)).read(null);
        
        //Calculate the affine transformations to map point between images.
        AffineTransform at0 = RendererUtilities.worldToScreenTransform(
                new ReferencedEnvelope(
                    src0.getEnvelope2D(), 
                    src0.getCoordinateReferenceSystem()
                ),
                new Rectangle(
                    src0.getRenderedImage().getWidth(),
                    src0.getRenderedImage().getHeight()
                )
        ).createInverse();
        AffineTransform at1 = RendererUtilities.worldToScreenTransform(
                new ReferencedEnvelope(
                    src1.getEnvelope2D(), 
                    src1.getCoordinateReferenceSystem()
                ),
                new Rectangle(
                    src1.getRenderedImage().getWidth(),
                    src1.getRenderedImage().getHeight()
                )
        );
        
        /* Produce the same result as above... So can I use it instead?
        AffineTransform at0 = (AffineTransform)
src0.getGridGeometry().getGridToCRS();
        AffineTransform at1 = (AffineTransform)
src1.getGridGeometry().getGridToCRS().inverse();
         */
        
        //Map the first image's center into second image.
        Point2D.Double p0 = new Point2D.Double(
                src0.getRenderedImage().getWidth() / 2d,
                src0.getRenderedImage().getHeight() / 2d);
        Point2D.Double p1 = (Point2D.Double) 
                at1.transform(
                    at0.transform(
                        p0, null), 
                    null);
        
        //Writes the results. The method pointMark creates a 31x31 boundbox 
        //around the points once calculated.
        GridCoverage2D dest0 = pointMark(src0, p0);
        GridCoverage2D dest1 = pointMark(src1, p1);
        (new GeoTiffWriter(new File("images/tmp0.tif"))).write(dest0, null);
        (new GeoTiffWriter(new File("images/tmp1.tif"))).write(dest1, null);

        ...

Is My code wrong or is it possible the images are incorrectly geo
referenced? How can I workaround on this?

All files - project, images and metadatas - are zipped into a test case (
http://www.nabble.com/file/p20109846/CoverageTest.zip CoverageTest.zip ).
Thanks for any help.

José
-- 
View this message in context: 
http://www.nabble.com/Problem-with-images-world-coordinates-tp20109846p20109846.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to