A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://stackoverflow.com/questions/79695288/saving-dataarray-through-to-netcdf-loses-coordinates below:

python xarray - Saving DataArray through to_netcdf loses coordinates?

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?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4