[Proj] mercator projection to spherical ellipsoid from WGS84

Melita Kennedy mkennedy2 at earthlink.net
Tue Mar 27 18:28:35 PDT 2007


Scott,

The reason why you got different results in cs2cs the first time is because you set the input datum to wgs84 and you provided datum transformation parameters in +towgs84=0,0,0. The code did this: 

1. Input degrees were converted to XYZ (3D Cartesian) using wgs84 ellipsoid parameters
2. Datum transformation performed - no change because the parameters were zeroes
3. Output XYZ values converted to decimal degrees using sphere parameters 
4. Output degrees projected to Mercator

This causes a latitude shift that you won't see if the datum transformation code is bypassed or you set the input ellipsoid/sphere to match the output. 

Melita 

------------------------------
Date: Tue, 27 Mar 2007 11:10:04 -0400
From: "Scott Ellington" <scott.ellington at goisc.com>
Subject: [Proj] mercator projection to spherical ellipsoid from WGS84:
	question
To: <proj at lists.maptools.org>

Hello,

I am trying to use mapserver to reproject some data I have so that it
will display on top of Microsoft's Virtual Earth.  VE uses a Mercator
projection with a spherical ellipsoid.  Details here:

http://msdn2.microsoft.com/en-us/library/bb259689.aspx

Unfortunately, I am having trouble working out the science behind
getting this reprojection working.  I have put together a set of proj
parameters to describe the output VE projection as so:

+proj=merc +ellps=sphere +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +no_defs

And my input data is in WGS84 lat/long:

+proj=latlong +datum=WGS84

However, specifying this as the input and output projection causes my
data to shift downward about 10 minutes of latitude.  I ran some tests
from the command line:

$ proj +proj=merc +ellps=sphere +a=6378137 +b=6378137 +lat_ts=0.0
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +no_defs
-84 30
-9350837.23     3503549.84  <---- This is correct

$ cs2cs +proj=latlong +datum=WGS84 +to +proj=merc +ellps=sphere
+a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0
+k=1.0
+units=m +towgs84=0,0,0 +no_defs
-84 30
-9350837.23     3482183.15 -5312.58 <--- Not correct.  Y value is
shifted downward

Yet, if I tell proj that my input data is already based on a spherical
ellipsoid, it works:

$ cs2cs +proj=latlong +ellps=sphere +a=6378137 +b=6378137 +lat_ts=0.0
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +no_defs +to +proj=merc
+ellps=sphere +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0
+y_0=0 +k=1.0 +units=m +no_defs
-84 30
-9350837.23     3503549.84 0.00 <-- correct

So my workaround has been to specify the input projection in mapserver
as spherical, when it is not, it is WGS84.  My question is this:  Why is
it necessary to do this?  Is there another way to write this cs2cs
reprojection which will allow me to correctly specify my input
projection?

Thanks in advance,

Scott Ellington
------------------------------




More information about the Proj mailing list