Skip to content

Commit

Permalink
Fix CRS being WKT instead of PROJ.4 (#2715)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Fix indentation on rasterio AttributeError check

* Add CRS WKT fix to whats-new
  • Loading branch information
djhoese authored and shoyer committed Feb 6, 2019
1 parent e677b7a commit 0c73a38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Bug fixes
:py:class:`CFTimeIndex` now results in a :py:class:`pandas.TimedeltaIndex`
instead of raising a ``TypeError`` (:issue:`2671`). By `Spencer Clark
<https://github.com/spencerkclark>`_.
- Fix ``open_rasterio`` creating a WKT CRS instead of PROJ.4 with
``rasterio`` 1.0.14+ (:issue:`2715`).
By `David Hoese <https://github.com/djhoese`_.

.. _whats-new.0.11.3:

Expand Down
5 changes: 4 additions & 1 deletion xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None,
# CRS is a dict-like object specific to rasterio
# If CRS is not None, we convert it back to a PROJ4 string using
# rasterio itself
attrs['crs'] = riods.crs.to_string()
try:
attrs['crs'] = riods.crs.to_proj4()
except AttributeError:
attrs['crs'] = riods.crs.to_string()
if hasattr(riods, 'res'):
# (width, height) tuple of pixels in units of CRS
attrs['res'] = riods.res
Expand Down

0 comments on commit 0c73a38

Please sign in to comment.