8000 [Bug]: Data is loading with lon/lat transposed · Issue #230 · google/Xee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Bug]: Data is loading with lon/lat transposed #230

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

Open
1 task done
alexgleith opened this issue May 8, 2025 · 2 comments
Open
1 task done

[Bug]: Data is loading with lon/lat transposed #230

alexgleith opened this issue May 8, 2025 · 2 comments
Labels
enhancement New feature or request P2

Comments

@alexgleith
Copy link

Bug Summary

I'm running the below code to load an xarray, and if I don't transpose lat/lon, then the array is flipped along a diagonal axis.

Am I doing something wrong to cause the data to be flipped?

Steps to Reproduce

import ee
import xarray as xr
import odc.geo.xr  # noqa: F401

# Authenticate and initialize
# ee.Authenticate()
ee.Initialize(opt_url="https://earthengine-highvolume.googleapis.com")

dataset = "ACA/reef_habitat/v2_0"
ic = ee.ImageCollection(ee.Image(dataset))

# Region of interest. Eventually, we need to do all of -180 to 180 and -32 to 32
left = 142.0
bottom = -10.0
right = 144.0
top = -8.0

# Close to full resolution
res = 0.00005
transform = [res, 0, left, 0, -res, top]

ds = xr.open_dataset(
    ic,
    engine='ee',
    geometry=[left, bottom, right, top],
    projection=ee.Projection(
        crs="epsg:4326", transform=transform
    ),
    chunks={"time": 1, "lon": 10000, "lat": 10000},
).squeeze().drop_vars("time")

# Load into memory and clean up
reef_mask = ds.reef_mask.astype("uint8").compute()
reef_mask = reef_mask.transpose("lat", "lon")  # Why is it transposed?!
reef_mask.odc.nodata = 0

reef_mask.odc.write_cog("test.tif", overwrite=True)

Current Behavior

Data is flipped

Expected Behavior

Data comes out in the right orientation

Relevant log output

Xee Version

0.0.20

Contact Details

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@alexgleith alexgleith added bug Something isn't working triage A new issue that needs to be triaged labels May 8, 2025
@jdbcode
Copy link
Member
jdbcode commented May 8, 2025

Hey Alex! Thanks for bringing this up. It's currently working as initially intended (x / lon, y / lat), but we're planning to introduce a breaking change to (y / lat, x / lon) to be more compatible with plotting for the majority of geospatial libraries and software.

You can see and add to the discussion at #196. Our plan is to release a new version that includes #225 and the transposed coordinates. This work is not scheduled until ~mid H2 this year.

@jdbcode jdbcode added enhancement New feature or request P2 and removed bug Something isn't working triage A new issue that needs to be triaged labels May 8, 2025
@alexgleith
Copy link
Author

Maybe this is a bit of a misunderstanding on my part... I just assumed that if xarray has labelled axes, the order wouldn't matter!

Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2
Projects
None yet
Development

No branches or pull requests

2 participants
0