Closed bertcoerver closed 1 year ago
The value for the nodata is what is used to fill in the regions without data. If you don't provide one, rioxarray will use the limits of the datatype you are using. If you want to use nan
for your fill value, that is valid. For more details, see:
https://corteva.github.io/rioxarray/stable/getting_started/nodata_management.html
data_ds.rio.write_nodata(numpy.nan, inplace=True)
The value for the nodata is what is used to fill in the regions without data. If you don't provide one, rioxarray will use the limits of the datatype you are using. If you want to use
nan
for your fill value, that is valid. For more details, see: https://corteva.github.io/rioxarray/stable/getting_started/nodata_management.html
Yes but the regions in my dataset without data are not filled with that value (1.7976931348623157e+308
), but with np.nan
, so it's incorrect right?
That attribute will give problems when trying to save to disk and providing a _FillValue
as encoding. I thought that in xarray pixels with _FillValue
are replaced with np.nan
and the attribute is removed when opening data. Unless when mask_and_scale = False
is passed to xr.open_dataset
in which case the data will actually contain the _FillValue
(such as 1.7976931348623157e+308
) and the attribute will be present to notify you that those values indicate missing data.
If you do:
data_ds.rio.write_nodata(numpy.nan, inplace=True)
Then rioxarray will use numpy.nan
as your fill value. If you don't tell it to use numpy.nan
and a different fill value is not in the encoded nodata, rioxarray will choose a nodata value based on the dtype.
More details here: https://corteva.github.io/rioxarray/stable/getting_started/nodata_management.html
ok, thanks for the help.
Code Sample, a copy-pastable example if possible
Problem description
When matching two datasets with each other using
rio.reproject_match
, each variable in the output dataset has an_FillValue
attribute that is (1) very large, giving problems when saving (OverflowError: Python int too large to convert to C long), (2) unnecessary, since the arrays for each variable contain np.nan's, (3) unused since the value isn't present in the array.I can fix it by removing the attribute manually, but it would be more convenient if it wasn't added at all. Hadn't noticed this before, so perhaps it's related to some changes in the latest version (0.12.0)?
Environment Information
Installation method
conda install -c conda-forge rioxarray
Conda environment information (if you installed with conda):
Environment (
conda list
):Details about
conda
and system (conda info
):