[Bug]: Data is loading with lon/lat transposed
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
- [x] I agree to follow this project's Code of Conduct
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.
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.