-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Problem description
Currently the way data is stored in the dataaray when using xarray.open_rasterio
the crs and nodata information is stored in an attributes. It would be nice to be able to have them stored in standard locations so that other tools (rasterio, QGIS, GDAL) can find the information properly after dumping to a file with to_netcdf()
.
Proposed solutions
The nodata should be loaded into _FillValue
I propose that the CRS information be stored using the CF spatial_ref
convention as it is supported by the main open source GIS tools. To do so, you add the crs
coordinate to the dataset/dataarray. And then, you add the spatial_ref
attribute to the crs
which is stored as a crs WKT string. Next, you add the grid_mapping
attribute to all associated variables that contains the coordinate name crs
as the grid_mapping
.
Here is an example of how it would look on a dataset:
<xarray.Dataset>
Dimensions: (x: 65, y: 31)
Coordinates:
* x (x) float64 ...
* y (y) float64 ...
time datetime64[ns] ...
crs int64 ...
Data variables:
ndvi (y, x) float64 ...
Attributes:
Here is how the crs
or spatial_ref
coodinate variable would look:
<xarray.DataArray 'crs' ()>
array(0)
Coordinates:
time datetime64[ns] ...
crs int64 0
Attributes:
spatial_ref: PROJCS["UTM Zone 15, Northern Hemisphere",GEOGCS["WGS 84",D...
And here is how it would look on the variables:
<xarray.DataArray 'ndvi' (y: 31, x: 65)>
array([[ ...]])
Coordinates:
* x (x) float64 ...
* y (y) float64 ...
time datetime64[ns] ...
crs int64 0
Attributes:
grid_mapping: crs
More information about this is in #2288.