Skip to content

Commit 0c73a38

Browse files
djhoeseshoyer
authored andcommitted
Fix CRS being WKT instead of PROJ.4 (#2715)
* Fix CRS being WKT instead of PROJ.4 See https://github.com/mapbox/rasterio/blob/master/CHANGES.txt#L7 * Fix rasterio usage for older rasterio without to_proj4 Co-Authored-By: djhoese <david.hoese@ssec.wisc.edu> * Fix indentation on rasterio AttributeError check * Add CRS WKT fix to whats-new
1 parent e677b7a commit 0c73a38

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Bug fixes
7979
:py:class:`CFTimeIndex` now results in a :py:class:`pandas.TimedeltaIndex`
8080
instead of raising a ``TypeError`` (:issue:`2671`). By `Spencer Clark
8181
<https://github.com/spencerkclark>`_.
82+
- Fix ``open_rasterio`` creating a WKT CRS instead of PROJ.4 with
83+
``rasterio`` 1.0.14+ (:issue:`2715`).
84+
By `David Hoese <https://github.com/djhoese`_.
8285

8386
.. _whats-new.0.11.3:
8487

xarray/backends/rasterio_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None,
282282
# CRS is a dict-like object specific to rasterio
283283
# If CRS is not None, we convert it back to a PROJ4 string using
284284
# rasterio itself
285-
attrs['crs'] = riods.crs.to_string()
285+
try:
286+
attrs['crs'] = riods.crs.to_proj4()
287+
except AttributeError:
288+
attrs['crs'] = riods.crs.to_string()
286289
if hasattr(riods, 'res'):
287290
# (width, height) tuple of pixels in units of CRS
288291
attrs['res'] = riods.res

0 commit comments

Comments
 (0)