Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasterio backend not supporting complex_int16 type #5491

Closed
agrouaze opened this issue Jun 18, 2021 · 3 comments
Closed

rasterio backend not supporting complex_int16 type #5491

agrouaze opened this issue Jun 18, 2021 · 3 comments

Comments

@agrouaze
Copy link

agrouaze commented Jun 18, 2021

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!

@keewis
Copy link
Collaborator

keewis commented Jun 18, 2021

Thanks for the report, @Grouny. That seems like a simple fix so I think we would welcome a PR.

However, keep in mind that we are currently considering the deprecation of the builtin "rasterio" backend (along with the open_rasterio function) in favor of the one provided by rioxarray (see #4697). There's already a PR to fix this issue: corteva/rioxarray#353

@sjvrijn
Copy link
Contributor

sjvrijn commented Feb 28, 2023

Both #4697 and corteva/rioxarray#353 have been merged, so this issue can be closed

@dcherian
Copy link
Contributor

Thanks @sjvrijn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants