Skip to content

rasterio backend not supporting complex_int16 type #5491

Closed
@agrouaze

Description

@agrouaze

Dear xarray team,
problem : rasterio xarray's backend doesn't support complex_int16 dtype.
cmd :
xarray.open_rasterio(tiff)
error :

----> 4 xarray.open_rasterio(tiff)

/home1/datawork/agrouaze/conda_envs2/envs/xsar_gdal3.3_v2/lib/python3.8/site-packages/xarray/backends/rasterio_.py in open_rasterio(filename, parse_coordinates, chunks, cache, lock)
    371                 attrs[k] = v
    372 
--> 373     data = indexing.LazilyIndexedArray(RasterioArrayWrapper(manager, lock, vrt_params))
    374 
    375     # this lets you write arrays loaded with rasterio

/home1/datawork/agrouaze/conda_envs2/envs/xsar_gdal3.3_v2/lib/python3.8/site-packages/xarray/backends/rasterio_.py in __init__(self, manager, lock, vrt_params)
     40         if not np.all(np.asarray(dtypes) == dtypes[0]):
     41             raise ValueError("All bands should have the same dtype")
---> 42         self._dtype = np.dtype(dtypes[0])
     43 
     44     @property

TypeError: data type 'complex_int16' not understood

versions :
rasterio == 1.2.4
gdal == 3.3.0
numpy == 1.20.4
xarray == 0.18.2
system : Linux Ubuntu 16.04.7
Python 3.8.10

possible patch in xarray/backends/rasterio_.py line 42:

     if dtypes[0]!='complex_int16':#patch agrouaze June 2021
            self._dtype = np.dtype(dtypes[0])
     else:
            self._dtype = np.complex

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions