Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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()
srs2.SetWellKnownGeogCS("EPSG:4326")

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

transf = CoordinateTransformation(srs2,srs)
transf.TransformPoint((2.403,41.602))

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

What am I doing wrong?

share|improve this question

1 Answer 1

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

 
discard

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.