rioxarray
rioxarray copied to clipboard
Implement checking of compatibility on arbitrary xarray objects
Can we add a method to check if a given xarray object is compatible with/has all the necessary metadata to use rioxarray?
I understand different functions require different pieces of metadata, maybe on failure it can still print which methods are runnable with partial metadata
Sounds like that could be useful. Here are some references for metadata usage in rioxarray:
- https://corteva.github.io/rioxarray/stable/getting_started/manage_information_loss.html
- https://corteva.github.io/rioxarray/stable/getting_started/crs_management.html
- https://corteva.github.io/rioxarray/stable/getting_started/nodata_management.html
Did you have thoughts on what the behavior would be? Would it print a report of what attributes are found and what is missing? Or would it just raise an error when missing attributes are encountered?
I am thinking it could be both? A user calling it directly should print a report and internally this could be run before certain functions and be a single place for raising missing metadata errors
Each of the functions already calls the attributes needed and raises appropriate errors for the subsets of information that are missing. To keep things simple, what I am thinking the new function could do is just call all of the potentially necessary attributes, catch the errors and print a report of how compatible the xarray object is. It could also have a toggle to turn on/off raising exceptions.
Maybe something like:
rio.check_compatibility()