concat breaks raster stack #8038
Replies: 5 comments
-
Further investigation suggests this is similar / related to Issue #3681. Using edit: An old xarray 0.15.1 doesn't exhibit this behaviour and is correctly concated as expected. |
Beta Was this translation helpful? Give feedback.
-
Could it be that the coordinates of the individual arrays are not exactly the same? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I suspect there are floating point inaccuracies which can sometimes trip up xarray. But I would also not expect differences when the coords are created with the same piece of code. Unfortunately your test does not work - it will first align and then do the subtraction... Any of the following should work: (d0.y - d1.y).shape == d0.shape
d0.y.values == d1.y.values
xr.align(d0, d1, join="exact") If this worked earlier |
Beta Was this translation helpful? Give feedback.
-
Sorry for slow reply, I got pulled onto another task before Christmas and forgot to revisit. Hit this in a different way again today. I get a combo of mangled as well as NaN values.
Looking at x shows X off by
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
Loading multiple tiffs into a raster stack via
concat
,open_mfdataset
,open_dataset
,combine_by_coords
corrupts the data, causing them to not display correctly, or write out to disk correctly. The rasters show as banded outputs missing data.Plotting individual pre-stacked looks as expected.

If a slice of the stacked DA is written to a file, that file is also corrupted. This is confirmed by loading the file in QGIS.
What did you expect to happen?
The stack to not mangle the data
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
nomax_tiff.zip
Environment
On a linux cluster:
xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.10 (default, Jun 16 2021, 14:20:20)
[GCC 9.3.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-1160.36.2.el7.x86_64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: ('en_CA', 'UTF-8')
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 2022.6.0+computecanada
pandas: 1.4.0
numpy: 1.22.2
scipy: 1.8.0
netCDF4: 1.5.8
pydap: None
h5netcdf: None
h5py: 3.1.0
Nio: None
zarr: None
cftime: 1.6.0
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.3.0
cfgrib: 0.9.10.1
iris: None
bottleneck: None
dask: 2022.7.0
distributed: None
matplotlib: 3.5.1
cartopy: 0.20.3
seaborn: 0.11.2
numbagg: None
fsspec: 2022.5.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 46.1.3
pip: 20.0.2
conda: None
pytest: None
IPython: 7.31.1
sphinx: None
This also reproduces on a macos install. But xr show_versions segfaults. No idea, seems weird.
Python 3.10.4 (main, Jun 14 2022, 14:00:56) [Clang 13.0.0 (clang-1300.0.27.3)] on darwin
rioxarray 0.12.4
xarray 2022.11.0
rasterio 1.3.3
Beta Was this translation helpful? Give feedback.
All reactions