-
-
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
added some logic to deal with rasterio objects in addition to filepaths #2589
Conversation
Hello @scottyhq! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on December 23, 2018 at 18:24 Hours UTC |
Following up on dask/dask#3255 @mrocklin, @shoyer, @jhamman |
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! I only have a few comments (I don't use these things myself), but the change seems harmless enough to me (once the tests pass ;).
Is there a way to test the functionality without actually going online?
And can you also add an entry to whatsnew.rst?
xarray/backends/rasterio_.py
Outdated
@@ -2,7 +2,8 @@ | |||
import warnings | |||
from collections import OrderedDict | |||
from distutils.version import LooseVersion | |||
|
|||
import rasterio | |||
from rasterio.vrt import WarpedVRT |
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.
Imports of optional dependencies can unfortunately not happen at the module top level - import them only when needed in the function scope
with xr.open_rasterio(tmp_file) as actual: | ||
assert_allclose(actual, expected) | ||
|
||
def test_rasterio_vrt(self): |
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 network tests we have a special decorator (@network
), see https://github.com/pydata/xarray/blob/55f21deff4c2b42bd6ead4dbe26a1b123337913a/xarray/tests/test_tutorial.py (although that's the only use of it as it seems?)
thanks for the feedback @fmaussion, I think I've addressed your suggestions, let me know if anything else needs adjusting |
xarray/backends/rasterio_.py
Outdated
@@ -123,6 +124,42 @@ def __getitem__(self, key): | |||
key, self.shape, indexing.IndexingSupport.OUTER, self._getitem) | |||
|
|||
|
|||
class RasterioVRTWrapper(RasterioArrayWrapper): |
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.
Rather than adding a subclass with a lot of duplicated logic, could you add this into the base RasterioArrayWrapper
class?
Something like:
def __init__(self, manager, vrt_params=None):
...
riods = riods if vrt_params is None else WarpedVRT(riods, **vrt_params)
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.
Good point, just moved the changes to RasterioArrayWrapper
def test_rasterio_vrt_network(self): | ||
import rasterio | ||
|
||
url = 'https://storage.googleapis.com/\ |
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.
I didn't even know this form of line-wrapping for strings was possible in Python :)
These tests are failing on our "py36-rasterio-0.36" build, e.g.,
Should we increase the minimum required version of rasterio or guard these imports? |
I think the minimum rasterio version should be increased to 1.0. For whatever reason the conda defaults channel hasn't been updated since 0.36 (Jun 14, 2016!). There are many important changes in 1.0 and beyond, and those releases are available via both pip and conda-forge. |
…into open-rasterio-vrt
I'd be personally fine bumping our minimum version of rasterio to 1.0. There have been multiple minor releases since then so I would suggest the 1.0 version has stabilized by now. |
OK, please update our installation page at docs/installing.rst, too. This should also definitely be mentioned in "what's new" |
@jjhelmus is there a good way to report things like this other than pinging you directly? (which I'm more than happy to continue doing :)) |
Opening and issue in the anaconda-issues repository is the best option at this time for requesting a package update. I'm looking at updating the |
… On Wed, Dec 19, 2018 at 4:14 PM Jonathan J. Helmus ***@***.***> wrote:
@jjhelmus <https://github.com/jjhelmus> is there a good way to report
things like this other than pinging you directly?
Opening and issue in the anaconda-issues
<https://github.com/ContinuumIO/anaconda-issues> repository is the best
option at this time for requesting a package update.
I'm looking at updating the rasterio package in defaults this week.
Something should be available by the end of the week.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2589 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszMr1wxsC7gjEdyH3dfrDU5kig_LBks5u6qwugaJpZM4Y_8DQ>
.
|
|
It looks like @jjhelmus resolved this upstream . It seems like https://github.com/ContinuumIO/anaconda-issues is a good issue tracker to know :) |
|
* master: DEP: drop python 2 support and associated ci mods (pydata#2637) TST: silence warnings from bottleneck (pydata#2638) revert to dev version DOC: fix docstrings and doc build for 0.11.1 Source encoding always set when opening datasets (pydata#2626) Add flake check to travis (pydata#2632) Fix dayofweek and dayofyear attributes from dates generated by cftime_range (pydata#2633) silence import warning (pydata#2635) fill_value in shift (pydata#2470) Flake fixed (pydata#2629) Allow passing of positional arguments in `apply` for Groupby objects (pydata#2413) Fix failure in time encoding for pandas < 0.21.1 (pydata#2630) Fix multiindex selection (pydata#2621) Close files when CachingFileManager is garbage collected (pydata#2595) added some logic to deal with rasterio objects in addition to filepaths (pydata#2589) Get 0d slices of ndarrays directly from indexing (pydata#2625) FIX Don't raise a deprecation warning for xarray.ufuncs.{angle,iscomplex} (pydata#2615) CF: also decode time bounds when available (pydata#2571)
|
…h strings
whats-new.rst
for all changes andapi.rst
for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)