Sorry, that I misuse this platform for my silly question:

I have a  dataset
Dimensions: (time: 1, band: 4, y: 8192, x: 4096)
Coordinates:
* time datetime64[ns] 8B 2023-06-15
* band <U5 80B 'Red' 'Green' 'Blue' 'Alpha'
* y float32 33kB 7.064e+06 7.064e+06
* x float32 16kB 1.194e+06 1.194e+06
Data variables:
band_data (time, band, y, x) uint8 134MB dask.array<chunksize=(1, 4, 1024, 1024), meta=np.ndarray>
spatial_ref int64 8B ...

1/2 #xarray #gdal #zarr

I added to "band_data" a '_CRS' attribute as dict with 'url', 'wkt' & 'projjson' infos (EPSG 3857), saved the whole thing as  file and hoped  can open it in  

However  seems to have trouble finding the coordinate reference and assumes the origin is 0,0 (Extent 0.0, -8192.0 : 4096.0, 0.0).

Now, my question: where do I store the "_CRS" dict correctly? Do I also need to add a GeoTransform infos? If yes, where?

2/2 #xarray #gdal #zarr

@Mixed_Pixels if memory serves me well, GDAL needs certain axis order, an attribute containing the statial info (crs, geotransform, generally called spatial_ref), and said attribute has to be specified as the grid mapping on the encoding. Ill try to give more details as soon as i get home.
@borlafgis thanks Ignacio, that would be terrific.

@Mixed_Pixels I think the easiest solution may be to use the rioxarray methods:

https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.rioxarray.XRasterBase.set_spatial_dims (I think it should take care of the ordering)

https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.rioxarray.XRasterBase.set_crs (should work if you pass "EPSG:3857")

https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.rioxarray.XRasterBase.write_transform (tell gdal/qgis where the raster should be placed)

They will manage the specifics for you, and you could use the output object as example if you wish to do these things manually

rioxarray package — rioxarray 0.20.0 documentation

@borlafgis thanks a lot. I will try this tomorrow morning.
@Mixed_Pixels now that i think about it, you may need to place your bands in separate variables, because I am unsure that gdal handles >3 dims.