[Gdal-dev] Converting Mercator Meters to Degrees
Chris Portka
cportka at newwireless.com
Wed Jan 31 14:55:31 EST 2007
I'm trying to convert a UTM easting value to a value an easting in
mercator meters and then to its correct longitude. The conversion from
UTM to mercator is fine and defined in the following way (I'm given a
proper UTM easting, northing, and zone):
OGRSpatialReference utm;
OGRSpatialReference mm;
OGRCoordinateTransformation *transform;
utm.SetProjCS("UTM / WGS84");
utm.SetWellKnownGeogCS("WGS84");
utm.SetUTM(UTMzone, TRUE);
mm.SetMercator(0, 0, 1, 0, 0);
mm.SetWellKnownGeogCS("WGS84");
transform = OGRCreateCoordinateTransformation(&utm, &mm);
if (transform == NULL) ...
double x = UTMEasting;
double y = UTMNorthing;
if (!transform->Transform(1, &x, &y)) ...
However, now I want to convert the easting (only the easting) to its
appropriate longitude value. Looking up the conversion from mercator
meters easting to longitude I get the following conversion:
longitude = (MMEasting / 6356752.3142) * 57.295779513082322;
OR longitude = (easting / earthRadius) * RadToDeg;
But this gives me a slightly different value (about .1 degrees smaller)
than if did the conversion with OGR like this:
OGRSpatialReference mm;
OGRSpatialReference latlon;
OGRCoordinateTransformation *transform;
mm.SetMercator(0, 0, 1, 0, 0);
mm.SetWellKnownGeogCS("WGS84");
latlon.SetWellKnownGeogCS("WGS84");
transform = OGRCreateCoordinateTransformation(&mm, &latlon);
if (transform == NULL) ...
double x = MMEasting;
double y = MMNorthing;
if (!transform->Transform(1, &x, &y)) ...
I don't want to do this whole conversion though because I only need the
longitude. Does anyone have an idea what I could be doing wrong in my
longitude conversion? Is there some kind of false easting or something
that gets set in SetMercator that could be giving me differing values? I
tried looking at the source for SetMercator, but it doesn't look like it
sets anything differently. Any help would be greatly appreciated.
Chris
More information about the Gdal-dev
mailing list