Sunday, 14 October 2018

python - pyProj Coordinate Transformation Incorrect


I'm using pyProj to transform extents between two different geographical systems. In a case when both my systems are the same I expect to get back the same extents as inputted but this isn't happening for the below mentioned case:


import pyproj
inProj = pyproj.Proj("+init=EPSG:{0}".format(3857)) # Mercator
outProj = pyproj.Proj("+init=EPSG:{0}".format(3857))
x = (-20037507.0672, 20037509.6184)
y = (-1467048.29156, 8625918.8737)
print pyproj.transform(inProj,outProj,x,y)


The output comes out to be : ((-20037507.0672, -20037507.067178484), (-1467048.2915600014, 8625918.873699998))


Which is incorrect as my X-Coordinate extents are same for xMax and xMin.


If I change my co-ordinate systems


import pyproj
inProj = pyproj.Proj("+init=EPSG:{0}".format(3857)) # Mercator
outProj = pyproj.Proj("+init=EPSG:{0}".format(4326)) # WGS84
x = (-20037507.0672, 20037509.6184)
y = (-1467048.29156, 8625918.8737)
print pyproj.transform(inProj,outProj,x,y)


My X-coordinate output comes out to be : (-179.99998854118687, -179.99998854099357)


Which is again incorrect. Is this due to a domain issue in pyProj or is there any other reason ?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...