[GIS] Convert coordinates to differnt Spatial Reference System in Python

coordinate systempython

I am trying to convert co-ordinates (-33.75, 150) from epsg:3857 to epsg:28356 in Python.

Using both of the examples in post How to convert projected coordinates to lat/lon using Python?, I get the following errors.

With ogr, osr:

"ERROR 1: latitude or longitude exceeded limits"

with projpy:

"RuntimeError: latitude or longitude exceeded limits"

What am I doing wrong?

EDIT: changing to epsg:4326 fixed the issue.

Best Answer

As @minus34 said above, you almost certainly have latitude and longitude, rather than eastings and northings, so your projection is likely to be WGS84 (or because you're in Australia, GDA94).

To do the transformation in pyproj (assuming GDA 94) you can use:

import pyproj

latitude, longitude = -33.75, 150.0

gda94 = pyproj.Proj(init='epsg:4283')
mgaz56 = pyproj.Proj(init='epsg:28356')

easting, northing = pyproj.transform(gda94, mgaz56, longitude, latitude)

Which gives you an easting and northing of:

222098.57102905802, 6261518.7214178415

For reference, the easting and northing in EPSG:3857 are:

16697923.61899104, -3995282.329507495