-
Notifications
You must be signed in to change notification settings - Fork 82
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
Valid VRT file with raster bands of with different dtype cannot be loaded #484
Comments
Interesting. Are you able to provide the input files? |
This may require #296 as the current method for loading brings it all into the same array. |
Looks like github doesn't allow uploading of vrt or xml files, so I've renamed it to .txt Note, this is just the virtual file. The real files are here: https://swift.rc.nectar.org.au/v1/AUTH_05bca33fce34447ba7033b9305947f11/landscapes-csiro-aet-public/v2_2/2021/2021_01_01/ |
I was looking into the sourcecode to see what it would take to fix it (thought it might be a quick simple fix) but I noticed that it loads all bands into one array, so yes I say it would need #296 before this can be fixed. |
Note, the example files I linked to above (the ones hosted on swift.rc.nectar.org.au) have now been replaced with VRT files with only a single band, to work around this problem. So they can no longer be used for reproducing/testing this issue. |
That sounds like a reasonable workaround. If you have a way of making a VRT with each file as a subdataset (so it would behave like a netCDF file), that would also be a nice workaround in my opinion. That way the datatype and other metadata would be separated into separate variables. Alternatively, one idea I had was that rioxarray could be modified to pick the largest data type and convert all of the other data types to the largest data type so data loss does not occur. However, this only works if the nodata value and other metadata are the same. Otherwise, it could be dangerous to do so. |
With #296 resolved, I believe this is resolved as well. |
Xarray, Rasterio, and rioxarray don't usually have any issue loading an VRT file in place of a real TIF file.
However in this case, have a valid VRT file that has two bands, each band has a different dtype (that is not valid in TIF file, but is valid in a VRT file), but rioxarray refuses to load it.
Code Sample
Problem description
ValueError("All bands should have the same dtype")
Expected Output
Xarray dataset with band each with their own given dtype.
Environment Information
The text was updated successfully, but these errors were encountered: