You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm willing to contribute a PR with the plugin, but I'd really prefer xr.open_dataset to map raster bands to data_vars not to a band coordinate, at least by default.
I'm willing to contribute a PR with the plugin, but I'd really prefer xr.open_dataset to map raster bands to data_vars not to a band coordinate, at least by default.
I'd really prefer xr.open_dataset to map raster bands to data_vars not to a band coordinate, at least by default.
This has been something that I have been on the fence about for the sake of consistency for the user. I think it would be good to have some input from others who might use this interface for their opinions on this.
As an alternative, when converting to a dataset, you could set the name of the DataArray to band_data. This makes selecting the band consistent with the current interface of open_rasterio.
I'd really prefer xr.open_dataset to map raster bands to data_vars not to a band coordinate, at least by default.
After giving it some more thought, I don't think we should go this route. This is due to the fact that GDAL also supports netCDF/HDF/grib/etc.. Within each of the data variables for those scenarios, there needs to be a mechanism to select the band (which could be named time). For consistency across the board, I think we should go with something more like: #197 (comment)
I think opening bands as variables or as a dimensions needs to be an option.
For example using bands as variables I can easily add xarray mask_and_scale support independently for every variable. This is a use case I'm interested in.
For example using bands as variables I can easily add xarray mask_and_scale support independently for every variable. This is a use case I'm interested in.
This sounds like modifications would be needed for rioxarray.open_rasterio to enable support for this in the backend entrypoint. Would you mind opening up a new issue to further discuss of your use case?
Activity
alexamici commentedon Apr 5, 2021
I'm willing to contribute a PR with the plugin, but I'd really prefer
xr.open_datasetto map raster bands to data_vars not to abandcoordinate, at least by default.@snowman2 would you evaluate such a PR?
snowman2 commentedon Apr 5, 2021
I would check whether it is a DataArray or Dataset returned by
rioxarray.open_rasterioas it could return either one depending on the input data: https://corteva.github.io/rioxarray/stable/examples/convert_to_raster.htmlsnowman2 commentedon Apr 5, 2021
This has been something that I have been on the fence about for the sake of consistency for the user. I think it would be good to have some input from others who might use this interface for their opinions on this.
As an alternative, when converting to a dataset, you could set the name of the DataArray to
band_data. This makes selecting the band consistent with the current interface ofopen_rasterio.For example:
snowman2 commentedon Apr 5, 2021
Another reason for doing it the way you suggest here allows adding band specific metadata in the
attrsfor eachdata_var.snowman2 commentedon Apr 5, 2021
Thanks for getting started on this @alexamici 👍
snowman2 commentedon Apr 5, 2021
After giving it some more thought, I don't think we should go this route. This is due to the fact that GDAL also supports netCDF/HDF/grib/etc.. Within each of the data variables for those scenarios, there needs to be a mechanism to select the band (which could be named
time). For consistency across the board, I think we should go with something more like: #197 (comment)alexamici commentedon Apr 5, 2021
I implemented the check for
xr.Datasetand reverted the mapping of bands to data_vars (but I still would prefer it).Current implementation returns:
alexamici commentedon Apr 5, 2021
I think opening bands as variables or as a dimensions needs to be an option.
For example using bands as variables I can easily add xarray
mask_and_scalesupport independently for every variable. This is a use case I'm interested in.snowman2 commentedon Apr 5, 2021
This sounds like modifications would be needed for
rioxarray.open_rasterioto enable support for this in the backend entrypoint. Would you mind opening up a new issue to further discuss of your use case?