Skip to content

Commit 78ca20a

Browse files
leeviannalaJoe Hamman
authored andcommitted
Fixed issue #1520, by adding a if-else that checks for None (#1526)
* Fixed issue #1520, by adding a if-else that checks for None * Changed the read_rasterio to skip CRS entirely if it is None * Added whats new comment on fix of issue #1520 * Resolved a conflict with master branch. * Deleted a line change from whats new
1 parent 4a15cfa commit 78ca20a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

doc/whats-new.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ Bug fixes
120120
objects with data stored as ``dask`` arrays (:issue:`1529`).
121121
By `Joe Hamman <https://github.com/jhamman>`_.
122122

123+
- :py:func:`~xarray.open_rasterio` method now skips rasterio.crs -attribute if
124+
it is none.
125+
By `Leevi Annala <https://github.com/leevei>`_.
126+
123127
.. _whats-new.0.9.6:
124128

125129
v0.9.6 (8 June 2017)
@@ -2028,4 +2032,4 @@ Miles.
20282032
v0.1 (2 May 2014)
20292033
-----------------
20302034

2031-
Initial release.
2035+
Initial release.

xarray/backends/rasterio_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ def open_rasterio(filename, chunks=None, cache=None, lock=None):
142142

143143
# Attributes
144144
attrs = {}
145-
if hasattr(riods, 'crs'):
145+
if hasattr(riods, 'crs') and riods.crs:
146146
# CRS is a dict-like object specific to rasterio
147-
# We convert it back to a PROJ4 string using rasterio itself
147+
# If CRS is not None, we convert it back to a PROJ4 string using
148+
# rasterio itself
148149
attrs['crs'] = riods.crs.to_string()
149150
if hasattr(riods, 'res'):
150151
# (width, height) tuple of pixels in units of CRS

0 commit comments

Comments
 (0)