1

I have the following code to transform coordinates:

from pyproj import Proj, transform

def transform_coordinates(coordinates):
    (x, y) = coordinates
    inProj  = Proj('EPSG:25832')
    outProj = Proj('EPSG:4326')
    lat, lon = transform(inProj,outProj,x,y)
    print(x,y, " -> ", lat, lon)
    return (lon, lat)

transform_coordinates((6559455.75409500021487474, 278682.56987731397384778))

I get the following:

6559455.754095 278682.569877314  ->  1.6901601579676362 56.71184635815745

When according to epsg.io, it should be (5.1333339, 59.1166659)

I could swear it was working yesterday.

EDIT:

inProj: Proj('+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs', preserve_units=True)

outProj: Proj('+proj=longlat +datum=WGS84 +no_defs', preserve_units=True)
  • 1
    please add the exact values of inProj and outProj (preferably via a print() statement) to confirm what the program is useing – Ian Turton Apr 27 at 10:02
2

Notice the difference between giving coordinates in northing-easting order vs. easting-northing.

gdaltransform -s_srs epsg:25832 -t_srs epsg:4326
Enter X Y [Z [T]] values separated by space, and press Return.

6559455.754095 278682.569877314
56.7118463581575 1.69016015796764 0

278682.569877314 6559455.754095
5.13333392148302 59.1166659475444 0

Notice also that since Proj6 the axis order of officially latitude-longitude and northing-easting coordinate systems may be used in a different way than with older Proj versions. Read "Axis order issues" from https://trac.osgeo.org/gdal/wiki/rfc73_proj6_wkt2_srsbarn.

EDIT:

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

You can use the Transformer with the always_xy option if you want a consistent axis order.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.