Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasterio backend: added nodatavals attribute #1740

Merged
merged 8 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ v0.10.1 (unreleased)

Enhancements
~~~~~~~~~~~~
- Added nodatavals attribute to dataset when using open_rasterio.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want you can credit yourself here. If you do so it would be good also to link to the original issue (see examples below) and to rename dataset do DataArray


Bug fixes
~~~~~~~~~
Expand Down
4 changes: 4 additions & 0 deletions xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def open_rasterio(filename, chunks=None, cache=None, lock=None):
# Affine transformation matrix (tuple of floats)
# Describes coefficients mapping pixel coordinates to CRS
attrs['transform'] = tuple(riods.transform)
if hasattr(riods, 'nodatavals'):
# The nodata values for the raster bands
attrs['nodatavals'] = tuple([np.nan if nodataval is None else nodataval
for nodataval in riods.nodatavals])

data = indexing.LazilyIndexedArray(RasterioArrayWrapper(riods))

Expand Down