-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
MCVE Code Sample
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:
<xarray.DataArray (band: 4, y: 409, x: 645)>
[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:
<xarray.DataArray (band: 4, y: 409, x: 645)>
[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:
<xarray.DataArray (band: 4, y: 409, x: 645)>
[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:
<xarray.DataArray (band: 4, y: 409, x: 645)>
[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