id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 566961374,MDU6SXNzdWU1NjY5NjEzNzQ=,3776,Exporting .nc using to_netdcf with open_rasterio() failes exporting all Attributes ,40687016,closed,0,,,2,2020-02-18T15:14:06Z,2023-03-29T16:01:46Z,2023-03-29T16:01:46Z,NONE,,,,"#### MCVE Code Sample ```python image = '/home/user/Desktop/LE07_L1TP_192028_20100208_20161217_01_T1_AOI_ITA_LS_TILE_192028.tif' data = xr.open_rasterio(image) data.to_netcdf('/home/elisavet/Desktop/LE07_L1TP_192028_20100208_20161217_01_T1_AOI_ITA_LS_TILE_19202.nc') ``` #### Expected Output The output should keep all attributes from the original file which are the following: ``` [1055220 values with dtype=float64] Coordinates: * band (band) int64 1 2 3 4 * y (y) float64 46.95 46.94 46.94 46.93 ... 45.13 45.12 45.12 45.12 * x (x) float64 10.59 10.6 10.6 10.61 10.61 ... 13.47 13.48 13.48 13.49 Attributes: transform: (0.004491576420597608, 0.0, 10.59113719976916, 0.0, -0.004... crs: +init=epsg:4326 res: (0.004491576420597608, 0.004491576420597608) scales: (1.0, 1.0, 1.0, 1.0) offsets: (0.0, 0.0, 0.0, 0.0) descriptions: ('NDVI', 'NDWI', 'NDMI', 'pixel_qa') ``` But what I get is: ``` [1055220 values with dtype=float64] Coordinates: * band (band) int64 1 2 3 4 * y (y) float64 46.95 46.94 46.94 46.93 ... 45.13 45.12 45.12 45.12 * x (x) float64 10.59 10.6 10.6 10.61 10.61 ... 13.47 13.48 13.48 13.49 Attributes: transform: (0.004491576420597608, 0.0, 10.59113719976916, 0.0, -0.00449... res: (0.004491576420597608, 0.004491576420597625) is_tiled: 0 nodatavals: (nan, nan, nan, nan) scales: (1.0, 1.0, 1.0, 1.0) offsets: (0.0, 0.0, 0.0, 0.0) ``` The output .nc is missing the crs and the descriptions which I want to keep after exporting #### Problem Description The output should keep all attributes from the original file which are the following: ``` [1055220 values with dtype=float64] Coordinates: * band (band) int64 1 2 3 4 * y (y) float64 46.95 46.94 46.94 46.93 ... 45.13 45.12 45.12 45.12 * x (x) float64 10.59 10.6 10.6 10.61 10.61 ... 13.47 13.48 13.48 13.49 Attributes: transform: (0.004491576420597608, 0.0, 10.59113719976916, 0.0, -0.004... crs: +init=epsg:4326 res: (0.004491576420597608, 0.004491576420597608) scales: (1.0, 1.0, 1.0, 1.0) offsets: (0.0, 0.0, 0.0, 0.0) descriptions: ('NDVI', 'NDWI', 'NDMI', 'pixel_qa') ``` But what I get is: ``` [1055220 values with dtype=float64] Coordinates: * band (band) int64 1 2 3 4 * y (y) float64 46.95 46.94 46.94 46.93 ... 45.13 45.12 45.12 45.12 * x (x) float64 10.59 10.6 10.6 10.61 10.61 ... 13.47 13.48 13.48 13.49 Attributes: transform: (0.004491576420597608, 0.0, 10.59113719976916, 0.0, -0.00449... res: (0.004491576420597608, 0.004491576420597625) is_tiled: 0 nodatavals: (nan, nan, nan, nan) scales: (1.0, 1.0, 1.0, 1.0) offsets: (0.0, 0.0, 0.0, 0.0) ``` The output .nc is missing the crs and the descriptions which I want to keep after exporting. #### Output of ``xr.show_versions()``
``` INSTALLED VERSIONS ------------------ commit: None python: 3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-76-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.8.18 libnetcdf: 4.4.1.1 xarray: 0.14.0 pandas: 0.25.2 numpy: 1.17.3 scipy: 0.19.1 netCDF4: 1.3.1 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.0 cfgrib: None iris: None bottleneck: None dask: 2.6.0 distributed: None matplotlib: 3.1.1 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.4.0 pip: 20.0.2 conda: None pytest: None IPython: 7.8.0 sphinx: None ```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3776/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue