Python Convert – Converting Projected Coordinates to Lat/Lon Using Python

convertcoordinate systempyprojpython

This site returns

Point:
X: -11705274.6374
Y: 4826473.6922

when you search with the first key value of 000090, as an example. I assume that this is a spatial reference.

I am looking for instructions, or examples, of how to convert this to latitude and longitude using Python.

Best Answer

The simplest way to transform coordinates in Python is pyproj, i.e. the Python interface to PROJ.4 library. In fact:

from pyproj import Proj, transform

inProj = Proj(init='epsg:3857')
outProj = Proj(init='epsg:4326')
x1,y1 = -11705274.6374,4826473.6922
x2,y2 = transform(inProj,outProj,x1,y1)
print x2,y2

returns -105.150271116 39.7278572773


EDIT based on Marc's comment:

pyproj 2.4 gives a FutureWarning about deprecated Proj initialization with the init= syntax. The updated syntax is identical but without the init=. Like this:

inProj = Proj('epsg:3857')
outProj = Proj('epsg:4326')