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

overview_level failing in xarray with engine='rasterio' due to missing doc? #755

Closed
rsignell opened this issue Mar 14, 2024 · 2 comments
Closed
Labels
bug Something isn't working documentation Documentation related issue good first issue Good for newcomers

Comments

@rsignell
Copy link

rsignell commented Mar 14, 2024

I use the awesome overview_level parameter in rioxarray all the time to explore big COG images before analysis.
I just recently tried using it with the invocation from xarray (with engine='rasterio') and it surprised me when it failed with:

TypeError: RasterioBackend.open_dataset() got an unexpected keyword argument 'overview_level'

Here's a MRE:

import xarray as xr
import rioxarray as rxr

https_url = 'https://s3.us-west-2.amazonaws.com/prod-is-usgs-sb-prod-publish/618e83cad34ec04fc9caa715/South_Carolina_CoNED_Topobathy_DEM_1m.tif'

da = rxr.open_rasterio(https_url, overview_level=6)   # works

ds = xr.open_dataset(https_url, engine='rasterio', backend_kwargs=dict(overview_level=6))  # doesn't work

I'm raising the issue here instead of on xarray repo because it seems perhaps the problem is that overview_level argument seems undocumented in the method:
https://corteva.github.io/rioxarray/stable/rioxarray.html#rioxarray-open-rasterio
and only exists in the documentation in the COG example here:
https://corteva.github.io/rioxarray/stable/examples/COG.html

Forgive me if I've got this all wrong! 🙃

@rsignell rsignell added the bug Something isn't working label Mar 14, 2024
@snowman2
Copy link
Member

You have to use open_kwargs. See:

open_kwargs=None,

@rsignell
Copy link
Author

rsignell commented Mar 15, 2024

Yep, so this works:

import xarray as xr

https_url = 'https://s3.us-west-2.amazonaws.com/prod-is-usgs-sb-prod-publish/618e83cad34ec04fc9caa715/South_Carolina_CoNED_Topobathy_DEM_1m.tif'

ds = xr.open_dataset(https_url, 
                     engine='rasterio', 
                     backend_kwargs=dict(open_kwargs={'overview_level':6},masked=True)
                     ).squeeze(drop=True)

thanks @snowman2 !

@snowman2 snowman2 added the documentation Documentation related issue label Mar 25, 2024
@snowman2 snowman2 added the good first issue Good for newcomers label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Documentation related issue good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants