I am using xarray and rioxarray to compute values from an existing dataset, the existing dataset as band like red, blue and green so I have something like this:
import xarray as xr
dataset: xr.Dataset = ...
red, blue, green = dataset["red"], dataset["blue"], dataset["green"]
gray = (red + blue + green) / 3.0
I then save three files:
red.to_netcdf("red.nc")
gray.to_netcdf("gray.nc")
gray.rio.to_raster("gray.tif")
I then open these files in QGIS: the red.nc and gray.tif files are at the right location, the gray.nc file is at the location (0, 0).
I tried to compare everything in the red and gray variables but I could not find any difference in term of attributes, etc.
How can I save gray as an NC file so that QGIS can open it properly?
.encoding. During calculation attributes/encoding might get dropped/changed. This get's fixed when writing out via rioxarray. Compare attributes/encoding between red/gray first, to check for differences.