rioxarray icon indicating copy to clipboard operation
rioxarray copied to clipboard

Implement checking of compatibility on arbitrary xarray objects

Open Zionett opened this issue 3 years ago • 3 comments

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

Zionett avatar Mar 01 '22 22:03 Zionett

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?

snowman2 avatar Mar 02 '22 14:03 snowman2

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

Zionett avatar Mar 03 '22 02:03 Zionett

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()

snowman2 avatar Mar 03 '22 14:03 snowman2