On Wed, Mar 9, 2011 at 1:30 PM, Peter Borissow <[email protected]>wrote:
> 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?
>
Mercator style projections diverge at the poles, if you look at Google maps
the map goes
from -80 to +80 in latitude.
Also, if you want to force geotools into using lon/lat order for geographic
data you have to
add this as the first line in your application code:
System.setProperty("org.geotools.referencing.forceXY", "true");
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
------------------------------------------------------------------------------
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