When using pyproj, note the differences from various releases in how it is used to transform data. Here are a few examples using new/old capabilities based on the question:
Using pyproj >= 2.2.0
import pyproj
print(pyproj.__version__) # 2.4.1
print(pyproj.proj_version_str) # 6.2.1
proj = pyproj.Transformer.from_crs(3857, 4326, always_xy=True)
x1, y1 = (-11705274.6374, 4826473.6922)
x2, y2 = proj.transform(x1, y1)
print((x2, y2)) # (-105.15027111593008, 39.72785727727918)
Using pyproj <= 1.9.6
import pyproj
print(pyproj.__version__) # 1.9.6
print(pyproj.proj_version_str) # 4.9.3
inProj = pyproj.Proj(init='epsg:3857')
outProj = pyproj.Proj(init='epsg:4326')
x1, y1 = (-11705274.6374, 4826473.6922)
x2, y2 = pyproj.transform(inProj, outProj, x1, y1)
print((x2, y2)) # (-105.15027111593008, 39.72785727727918)
There are a few considerations with the different versions of PROJ/pyproj:
transform
for older versions always return the same axis order of "x, y" or "longitude, latitude", whereas PROJ 6+ is the order as defined by EPSG, unless an option like always_xy=True
is specified
Proj
is limited to converting between geographic and projection coordinates within one datum, whereas the newer Transformer
takes into account datum shifts, and is recommended for newer pyproj use