Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swapped x,y coords in GDAL3 case #26

Closed
Kirill888 opened this issue May 14, 2020 · 1 comment
Closed

Swapped x,y coords in GDAL3 case #26

Kirill888 opened this issue May 14, 2020 · 1 comment
Assignees

Comments

@Kirill888
Copy link
Member

I know it's not merged yet, but I saw this code in Slack, and pretty sure this bit is wrong:

y, x, z = t.TransformPoint(p[1], p[0])

Should be

    x, y, z = t.TransformPoint(p[1], p[0]) 

order of projected coordinates is typically not swapped by CRS definition.

Also I would strongly suggest extracting and labeling lon/lat from p rather than using index based access, something like this up top: lon, lat = p, as this then clearly communicates the expected order of coordinates on input to the transform function.

@alexgleith
Copy link
Contributor

Yeah, you're right.

Here's the working code:

        lon, lat = p
        # GDAL 3 reverses coordinate order, because... standards
        if LON_LAT_ORDER:
            # GDAL 2.0 order
            x, y, z = t.TransformPoint(lon, lat)
        else:
            # GDAL 3.0 order
            x, y, z = t.TransformPoint(lat, lon)

        return [x, y]

Notes from here: OSGeo/gdal#1546

And an output projected extent that was tested.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants