# Convert coordinates to differnt Spatial Reference System in Python

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.

• Don't know enough about the Python approach, but your source coordinate system is most likely EPSG:4326 (WGS84 Lat/long). ESPG:3857 is the Web Mercator projection which is in metres. Apr 26, 2015 at 10:19

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
``````
• Nice one, functionally GDA94 and WGS84 are identical (toWGS = 0,0,0,0,0,0,0) and MGA Zone XX == WGS Zone XX South. However some software (including Esri) needs the transformation matrix to work properly - projecting GDA94/Geographic to WGS Zone XXs can be problematic - best to project to MGA Zone XX and then redefine as WGS Zone XXs. This is definitely not true for AGD84 and AGD66 (and AMG projections) should one be encountered. Apr 26, 2015 at 23:42