Convert EPSG:2263 to WGS84 Using Python Pyproj

pyproj

I'm trying to convert Projected bounds to WGS84 using Pyproj but getting strange results.

The Projected Bounds are : 909126.0155, 110626.2880, 1610215.3590, 424498.0529

The corresponding WGS84 Bounds (the target) are: -74.2700, 40.4700, -71.7500, 41.3100

The data is from: http://spatialreference.org/ref/epsg/nad83-new-york-long-island-ftus/

>>> from pyproj import Proj, transform
>>> inProj  = Proj("+init=EPSG:2236")
>>> outProj = Proj("+init=EPSG:3857")
>>> x1,y1 =  (110626.2880, 909126.0155)
>>> print(transform(inProj,outProj,x1,y1))
(-9122788.926222347, 3833518.013375292)

The outProj is based on my understanding of what Google Maps uses.

Best Answer

Look Converting EPSG:2284 to EPSG:4326 with pyproj (and many others...).

Pyproj expects degrees (lon, lat) or meters (x,y) as units but the unit of Projection: 2263 isUNIT["US survey foot"..., therefore you need to use preserve_units=True.

from pyproj import Proj, transform
inProj  = Proj("+init=EPSG:2263",preserve_units=True)
outProj = Proj("+init=EPSG:4326") # WGS84 in degrees and not EPSG:3857 in meters)
# swap x,y as mkennedy says
y1,x1 =  (110626.2880, 909126.0155)
print(transform(inProj,outProj,x1,y1))
(-74.2700000001129, 40.46999999990434)

Control with GDAL/OSR

from osgeo import osr
inp= osr.SpatialReference()
inp.ImportFromEPSG(2263)
out= osr.SpatialReference()
out.ImportFromEPSG(4326)
transformation = osr.CoordinateTransformation(inp,out)
print(transformation.TransformPoint(x1,y1))
(-74.27000000011289, 40.46999999990432, 0.0)

New : Now how do I reverse the result?

y1,x1 =  (110626.2880, 909126.0155) # and not x1,y1 =
lon,lat = transform(inProj,outProj,x1,y1)
print(lon, lat)
-74.2700000001129 40.46999999990434

Now reverse the result:

x, y = transform(outProj,inProj,lon,lat)
print(x,y)
909126.0155000015 110626.28799994898

And you get the original values if you use print(y,x)

print(y,x)
110626.28799994898 909126.0155000015