Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a coordinate transformation using GDAL/osr python bindings. I have a longitude an a latitude and I want to transform them into the mercator coordinates.

So I define the mercator projection as:

srs = osr.SpatialReference()
srs.SetMercator(41.602, 2.403, 1, 0, 0);

and the input point projection as

srs2 = osr.SpatialReference()

When I transform the point supposed to be 0,0 in the mercator projection, using

transf = CoordinateTransformation(srs2,srs)

The x result is 0, as expected, but the y is a high number: 3799198

What am I doing wrong?

share|improve this question
up vote 3 down vote accepted

It's a feature of the underlying Proj4 library, and the definition of a Mercator projection. When you set the latitude_of_origin value to 41.602, what you're really setting is the latitude of true scale - which can be visualised as reducing the diameter of the Mercator cylinder until it matches the diameter of the spheroid at that latitude. But the cylinder still points straight "up", so your value of 3799198 is the number of metres from the equator to your latitude of true scale. To counter this, you'll need to specify a false northing:

srs.SetMercator(41.602, 2.403, 1, 0, -3799198.5783426273)

Proj4 does have partial support for oblique Mercator projections, but it's sketchy at best and is unlikely to give you satisfactory results.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.