[Proj] mercator projection to spherical ellipsoid from WGS84: question

Oscar van Vlijmen ovv at hetnet.nl
Tue Mar 27 14:35:45 EST 2007


> From: "Scott Ellington"
> Date: Tue, 27 Mar 2007 11:10:04 -0400
> Subject: [Proj] mercator projection to spherical ellipsoid from WGS84:
> question


> $ 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
> 
> ...... 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?

It is possible to do mighty strange things with cs2cs, possibly even without
knowing it.
I can reproduce your "incorrect" numbers with the following procedure.

Take lon=-84, lat=30 deg. Put them on the WGS84 ellipsoid and convert to
geocentric coordinates with an ellipsoidal procedure.
Now set a sphere with a = 6378137 m and convert the geocentric coordinates
back to lat, lon on this sphere with a spherical procedure.
Then use these lat, lon to project with a spherical mercator projection.
I got indeed:
easting, northing, height = -9350837.227, 3482183.153, -5312.580

Remedy: do not use +towgs84=0,0,0 in your spherical case.





More information about the Proj mailing list