1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Wed, 6 Feb 2019 10:56:06 -0600
Origin: wget https://github.com/pydata/xarray/commit/0c73a38.patch
Bug-Debian: https://bugs.debian.org/922515
Subject: [PATCH] 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
---
doc/whats-new.rst | 3 +++
xarray/backends/rasterio_.py | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
--- a/doc/whats-new.rst
+++ b/doc/whats-new.rst
@@ -331,6 +331,9 @@ Enhancements
- A new CFTimeIndex-enabled :py:func:`cftime_range` function for use in
generating dates from standard or non-standard calendars. 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`_.
- When interpolating over a ``datetime64`` axis, you can now provide a datetime string instead of a ``datetime64`` object. E.g. ``da.interp(time='1991-02-01')``
(:issue:`2284`)
--- a/xarray/backends/rasterio_.py
+++ b/xarray/backends/rasterio_.py
@@ -281,7 +281,10 @@ def open_rasterio(filename, parse_coordi
# 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
|