-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix CRS being WKT instead of PROJ.4 #2715
Conversation
@djhoese sorry for the inconvenience! I didn't consider the change in rasterio 1.0.14 to be an API change because the behavior of |
xarray/backends/rasterio_.py
Outdated
@@ -282,7 +282,7 @@ 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() | |||
attrs['crs'] = riods.crs.to_proj4() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djhoese I recommend the following:
attrs['crs'] = riods.crs.to_proj4() | |
attrs['crs'] = riods.crs.to_dict() |
It's both forward and backward compatible. As far as I can tell from scanning the xarray source, the data array's crs attribute is rarely used, except as an argument to rasterio.transform where a dict should do just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgillies It's not just how xarray uses the crs attribute but users. The reason I made this PR was because the xarray crs attribute changed from PROJ4 to WKT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why does it need to be a PROJ.4 string in xarray?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, backwards compatibility. I don't think there is any other strong reason other than what the original developer chose (it is a fairly popular CRS format). If you think it should be WKT then that should probably go in its own issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason was serialization to NetCDF: attributes can't be dict or objects, and strings are a perfect representation of the CRS. Any other idea welcome though.
* Force rasterio version to fix PROJ4 to WKT change See pydata/xarray#2715 * Try escaping quotes in travis CI * Try single quotes in travis reqs * Try no quotes in travis config
can your merge from master? The failing tests should be solved by #2720 |
Hello @djhoese! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on February 06, 2019 at 16:49 Hours UTC |
@fmaussion Done. And I merged @snowman2's suggestion and fixed the indent (I'm guessing github's editor made it difficult to see but it was off by one indentation). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Let's discuss how to deal with WKT and proj4 in a separate issue
I'm going to merge this tomorrow unless there are further concerns |
Does this need a whats-new entry? |
Yes, I would recommend that here -- especially for cases where we're changing behavior without a deprecation cycle (which is sometime the best path forward) |
OK, good point. I do still try to lean towards adding notes about bug fixes in "what's new" but it isn't strictly required. |
Co-Authored-By: djhoese <[email protected]>
@shoyer Added something to the whats-new. Let me know if anything needs changing. |
thanks David, that looks great |
* master: typo in whats_new (pydata#2763) Update computation.py to use Python 3 function signatures (pydata#2756) add h5netcdf+dask tests (pydata#2737) Fix name loss when masking (pydata#2749) fix datetime_to_numeric and Variable._to_numeric (pydata#2668) Fix mypy errors (pydata#2753) enable internal plotting with cftime datetime (pydata#2665) remove references to cyordereddict (pydata#2750) BUG: Pass kwargs to the FileManager for pynio engine (pydata#2380) (pydata#2732) reintroduce pynio/rasterio/iris to py36 test env (pydata#2738) Fix CRS being WKT instead of PROJ.4 (pydata#2715) Refactor (part of) dataset.py to use explicit indexes (pydata#2696)
@shoyer Any idea when a 0.11.4 or 0.12 will be released? I'm trying to work around some other rasterio bugs and would like to remove the restriction on the rasterio version used in my CI tests, but that requires this PR. |
Hopefully quite soon! see #2777 for
current status
…On Tue, Mar 12, 2019 at 10:31 AM David Hoese ***@***.***> wrote:
@shoyer <https://github.com/shoyer> Any idea when a 0.11.4 or 0.12 will
be released? I'm trying to work around some other rasterio bugs and would
like to remove the restriction on the rasterio version used in my CI tests,
but that requires this PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2715 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1hs0lknMUSnOP9A_Qw0124V8HZllks5vV-SGgaJpZM4aUQen>
.
|
See https://github.com/mapbox/rasterio/blob/master/CHANGES.txt#L7 for the change in rasterio 1.0.14 and my conda-forge issue where I discovered this: conda-forge/gdal-feedstock#262
This was put in a bugfix (micro version number) release of rasterio which made it harder to discover. @sgillies @snowman2 I saw that you brought this up and how it affected xarray (https://rasterio.groups.io/g/dev/message/68). If this pull request is a duplicate of a fix one of you made let me know.
To xarray devs, if I need to make any other changes (whats-new?) also let me know.
whats-new.rst
for all changes andapi.rst
for new API