Hello-
    I am trying to do perform a simple reprojection test taking a WGS84 image 
to 
a "Google" map projection ("EPSG:900913"). I lifted code from this thread:

http://www.mail-archive.com/[email protected]/msg02294.html



Here's the code:

----------
BufferedImage bi = ImageIO.read(
   new File("C:/My Documents/earth.jpg"));

Envelope2D envelope = new Envelope2D(CRS.decode("EPSG:4326"),
    new java.awt.geom.Rectangle2D.Float(-180, -90, 360, 180) 
);

GridCoverage2D gc2d = new GridCoverageFactory().create("BMImage", bi, envelope);

GridCoverage2D gc2dProj =
    (GridCoverage2D)Operations.DEFAULT.resample(gc2d, 
CRS.decode("EPSG:900913"));

ImageIO.write(gc2dProj.getRenderedImage(), "JPEG",
   new File("/temp/reproject_out.jpg"));

----------

I'm getting the following error:

----------

Mar 9, 2011 7:06:56 AM 
org.geotools.referencing.operation.projection.MercatorPseudoProvider$Spherical 
transform
WARNING: Possible use of "Popular Visualisation Pseudo Mercator" projection 
outside its valid area.
Latitude 180░00.0'S is out of range (▒90░).
Exception in thread "main" 
org.geotools.coverage.processing.CannotReprojectException: Can't reproject grid 
coverage "BMImage".
...
Caused by: org.geotools.referencing.operation.projection.ProjectionException: 
Latitude 180░00.0'S is too close to a pole.
        at 
org.geotools.referencing.operation.projection.Mercator$Spherical.transformNormalized(Mercator.java:207)

...

----------

Operator error I'm sure. Any suggestions?

Thanks,
Peter



      

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to