pyproj4 / pyproj

Python interface to PROJ (cartographic projections and coordinate transformations library)
https://pyproj4.github.io/pyproj
MIT License
1.04k stars 210 forks source link

Invert lat lon "Transformer" #1368

Closed Runak33 closed 7 months ago

Runak33 commented 7 months ago

Hello, using the "Transform" function, I realized that the input parameters were reversed, if you enter "x1, x2" the output positions do not match, while reversing the order of the inputs, "y1, y2", the output positions match the input positions (as you can see in the figure, the coordinates are different by changing the order of the inputs)

from pyproj import Transformer

inProj = 'epsg:4326' outProj = 'epsg:32632' x1, y1 = 12.48497983, 41.91058812

transformer = Transformer.from_crs(inProj, outProj) lon, lat = transformer.transform(x1, y1) print("bug_lon :", lon, "bug lat :", lat)

transformer_corr = Transformer.from_crs(inProj, outProj) lon_corr, lat_corr = transformer.transform(y1, x1)

print("lon_correct :", lon_corr, "lat_correct :", lat_corr)

image

snowman2 commented 7 months ago

See: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6