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

deprecated synthaxe to open tiff using xarray #639

Closed
agrouaze opened this issue May 23, 2023 · 1 comment · Fixed by #640
Closed

deprecated synthaxe to open tiff using xarray #639

agrouaze opened this issue May 23, 2023 · 1 comment · Fixed by #640

Comments

@agrouaze
Copy link

Hello geoviews team,

ALL software version info

geoviews 1.9.5 pyhd8ed1ab_0 conda-forge
geoviews-core 1.9.5 pyha770c72_0 conda-forge
rioxarray 0.14.1 pyhd8ed1ab_0 conda-forge
xarray 2023.5.0 pyhd8ed1ab_0 conda-forge
Python 3.10.8
Ubuntu 22.04.2 LTS

Description of expected behavior and the observed behavior

geoviews.util.load_tiff() should open .tiff files. With xarray==2023.5.0 the syntaxe da = xr.open_rasterio(filename) is not valid anymore.
see the code.

Complete, minimal, self-contained example code that reproduces the issue

to reproduce the issue you can download any .tiff file.
I randomly fetch this one

In [1]: ff = '/tmp/file_example_TIFF_1MB.tiff'

In [2]: import geoviews as gv

In [3]: gv.load_tiff(ff)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 gv.load_tiff(ff)

File /opt/conda-envs/dev/lib/python3.10/site-packages/geoviews/util.py:644, in load_tiff(filename, crs, apply_transform, nan_nodata, **kwargs)
    642 with warnings.catch_warnings():
    643     warnings.filterwarnings('ignore')
--> 644     da = xr.open_rasterio(filename)
    645 return from_xarray(da, crs, apply_transform, nan_nodata, **kwargs)

AttributeError: module 'xarray' has no attribute 'open_rasterio'

While this file is readable with rioxarray for instance:

In [5]: import rioxarray

In [6]: rioxarray.open_rasterio(ff)
/opt/conda-envs/dev/lib/python3.10/site-packages/rioxarray/_io.py:1132: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.
  warnings.warn(str(rio_warning.message), type(rio_warning.message))  # type: ignore
Out[6]: 
<xarray.DataArray (band: 4, y: 434, x: 650)>
[1128400 values with dtype=uint8]
Coordinates:
  * band         (band) int64 1 2 3 4
  * x            (x) float64 0.5 1.5 2.5 3.5 4.5 ... 646.5 647.5 648.5 649.5
  * y            (y) float64 0.5 1.5 2.5 3.5 4.5 ... 430.5 431.5 432.5 433.5
    spatial_ref  int64 0
Attributes:
    TIFFTAG_DOCUMENTNAME:    /home/marta/Desktop/www/file ex/files/grafa/tiff...
    TIFFTAG_RESOLUTIONUNIT:  2 (pixels/inch)
    TIFFTAG_XRESOLUTION:     72.009003
    TIFFTAG_YRESOLUTION:     72.009003
    scale_factor:            1.0
    add_offset:              0.0

Stack traceback

File /opt/conda-envs/dev/lib/python3.10/site-packages/geoviews/util.py:644, in load_tiff(filename, crs, apply_transform, nan_nodata, **kwargs)
    642 with warnings.catch_warnings():
    643     warnings.filterwarnings('ignore')
--> 644     da = xr.open_rasterio(filename)
    645 return from_xarray(da, crs, apply_transform, nan_nodata, **kwargs)

AttributeError: module 'xarray' has no attribute 'open_rasterio'
@agrouaze
Copy link
Author

thank you @hoxbro !

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.

1 participant