Skip to content

transformer.from_crs flips X and Y in output when transforming #510

@prinsniels

Description

@prinsniels

Issue:
When creating a transformer via transformer.from_proj and calling transform on a coordinate set, I expect the same result as calling transform via a transformer created by transformer.from_crs. This does not hold. When creating a transformer via .from_crs the X and Y are switched. See code below.

using:
python 3.7
pyproj 2.4.2.post1

Code:

print(__version__)
RDX = 103392.0
RDY = 468608.6
p1 = 'epsg:28992'
p2 = 'epsg:4326'
t_proj = Transformer.from_proj(proj_from=Proj(init=p1), proj_to=Proj(init=p2))
t_crs = Transformer.from_crs(crs_from=p1, crs_to=p2)
print(f"FROM_PROJ => {t_proj.transform(xx=RDX, yy=RDY)}")
print(f"FROM_CRS => {t_crs.transform(xx=RDX, yy=RDY)}")
coords_proj = t_proj.transform(xx=RDX, yy=RDY)
coords_crs = t_crs.transform(xx=RDX, yy=RDY)
print("Equal",  coords_crs == coords_proj)
print("Flipped", coords_crs[0] == coords_proj[1] and coords_crs[1] == coords_proj[0])

Result:
2.4.2.post1
FROM_PROJ => (4.632256139162482, 52.20316882027802)
FROM_CRS => (52.20316882027802, 4.632256139162482)
Equal False
Flipped True

I tried this for multiple epsg codes, all show the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    axis-orderIssue related to axis order changes introduced in PROJ 6.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions