Description
To be compatible with rioxarray
one needs to use stackstac.stack(..., xy_coords="center")
when computing X/Y coordinate values. When using this mode on data that contains "inverted Y axis", a most common scenario, Y axis coordinates are offset by 1 pixel size into positive direction.
I have made a small reproducer. Data is a global synthetic image with 1 degree per pixel in EPSG:4326
, when loading it with xy_coords="center"
you would expect Y coordinate to span from -89.5 to 89.5
, but instead it goes from 90.5 to -88.5
.
https://nbviewer.org/gist/Kirill888/b3dad8afdc10b37cd21af4aea8f417e3/stackstac-xy_coords-error-report.ipynb
https://gist.github.com/Kirill888/b3dad8afdc10b37cd21af4aea8f417e3
This causes issue reported earlier here: #68
Code that performs computation of the coordinate just offsets "top-left" coordinate by positive half pixel size, but instead should offset by sign(coord[1] - coord[0])*abs(resolution)*0.5