I have around 5000 geotiff files each of (25000,25000) with data value float32.
I wanted to calculate .argmax() across 5000 arrays.
So, first tried by merging the data arrays.
import xarray, rioxarray
rasters = [rioxarray.open_rasterio(f) for f in files]
merged = xarray.concat(rasters,dim=“band”)
I m struggled with the following error.
Traceback (most recent call last):
File “”, line 42, in
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/concat.py”, line 192, in concat
objs, dim, data_vars, coords, compat, positions, fill_value, join, combine_attrs
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/concat.py”, line 527, in _dataarray_concat
combine_attrs=“drop”,
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/concat.py”, line 384, in _dataset_concat
align(*datasets, join=join, copy=False, exclude=[dim], fill_value=fill_value)
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/alignment.py”, line 354, in align
copy=copy, fill_value=fill_value, indexers=valid_indexers
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/dataset.py”, line 2630, in reindex
**indexers_kwargs,
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/dataset.py”, line 2661, in _reindex
sparse=sparse,
File “/home/laura/.local/lib/python3.6/site-packages/xarray/core/alignment.py”, line 567, in reindex_variables
“index has duplicate values” % dim
ValueError: cannot reindex or align along dimension ‘x’ because the index has duplicate values
I tried by putting compat = override or no_conflicts. But, I got same error.
Could someone help me ?