I am trying to convert a GeoTIFF file into NetCDF file (still remains all the information) using either rioxarray or xarray in python. The file is just empty. But when I checked the GeoTIFF file it looks fine to me. I now have no idea why it is not successfully converted and cannot find the solutions. Below are the ones that I have tried:

With rioxarray.open_rasterio() and to_netcdf()

raster = rioxarray.open_rasterio("example_raster.tiff")

With rioxarray.open_rasterio() and rio.to_raster()

raster = rioxarray.open_rasterio("example_raster.tiff")

With xarray.open_rasterio() and rio.to_raster()

raster = xarray.open_rasterio("example_raster.tiff")

With xarray.open_dataset() and to_netcdf()

raster = xarray.open_dataset("example_raster.tiff")

They all give the empty outputs (when I put them into QGIS to see).

Do you know how to solve this problem?

Here is the file https://ufile.io/ztjbk8pt (choose Free Download --> Slow Speed).


I looked at this and it appears there is a bug in how the x/y coordinates are generated internally in xarray/rioxarray.

Fix oncoming: https://github.com/corteva/rioxarray/pull/401

  • Hi snowman2, sorry for late reply, but thank you so much I think it worked with the new xarray/rioxarray package.
    – Happier
    Sep 30 at 4:17
  • Glad to hear that it works 👍
    – snowman2
    Sep 30 at 13:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.