7

I'm trying to interpolate between coordinates, as a step in that process I convert latlong to UTM so I can work in metric.

I don't get the expected latlong when converting back, reproduced below:

>>> import pyproj
>>> pyproj.__version__
'1.9.2'
>>> p = pyproj.Proj("+proj=utm +zone=33 +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
>>> p(58.4, 15.6)
(5579373.890337878, 2328887.997220567)
>>> p(*p(58.4, 15.6), inverse=True) # Should return (58.4, 15.6)
(58.284316956873305, 15.63501250163002)

Is there a good explanation for this? How do I do what I want without this issue?

1 Answer 1

11

Your input coordinates are in the wrong order. Pyproj expects long, lat.

>>> import pyproj
>>> p = pyproj.Proj(init='epsg:32633')
>>> p(*p(15.6, 58.4), inverse=True)
(15.6, 58.399999999999991)
2
  • Subtle, thought it could be because projection/rounding errors, couldn't figure out how though. Thanks a lot! Commented Jan 22, 2013 at 17:33
  • 1
    Many transforms are only reversible within a restricted area. Check out the red strip in the map at spatialreference.org/ref/epsg/32633. Outside your UTM zone, the algorithm's robustness decreases.
    – sgillies
    Commented Jan 22, 2013 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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