Skip to content

Commit

Permalink
Kwargs to rasterio open (#5609)
Browse files Browse the repository at this point in the history
* Added kwargs option to be passed to rasterio.open

* Added description to whats-new.rst

* Fixed whitespace

* Update doc/whats-new.rst

Co-authored-by: Deepak Cherian <[email protected]>

* Update doc/whats-new.rst

Co-authored-by: keewis <[email protected]>

* Updated whats-new.rst

* Merged backend_kwargs with kwargs

* Added check for no kwargs

* Update doc/whats-new.rst

Co-authored-by: keewis <[email protected]>

* Removed backend_kwargs

Co-authored-by: Deepak Cherian <[email protected]>
Co-authored-by: keewis <[email protected]>
  • Loading branch information
3 people authored Jul 30, 2021
1 parent da99a56 commit 78cec7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ New Features
- Allow removal of the coordinate attribute ``coordinates`` on variables by setting ``.attrs['coordinates']= None``
(:issue:`5510`).
By `Elle Smith <https://github.com/ellesmith88>`_.
- Added ``**kwargs`` argument to :py:meth:`open_rasterio` to access overviews (:issue:`3269`).
By `Pushkar Kopparla <https://github.com/pkopparla>`_.
- Added :py:meth:`DataArray.to_numpy`, :py:meth:`DataArray.as_numpy`, and :py:meth:`Dataset.as_numpy`. (:pull:`5568`).
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Units in plot labels are now automatically inferred from wrapped :py:meth:`pint.Quantity` arrays. (:pull:`5561`).
Expand Down
17 changes: 15 additions & 2 deletions xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ def default(s):
return parsed_meta


def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None, lock=None):
def open_rasterio(
filename,
parse_coordinates=None,
chunks=None,
cache=None,
lock=None,
**kwargs,
):
"""Open a file with rasterio (experimental).
This should work with any file that rasterio can open (most often:
Expand Down Expand Up @@ -272,7 +279,13 @@ def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None, loc
if lock is None:
lock = RASTERIO_LOCK

manager = CachingFileManager(rasterio.open, filename, lock=lock, mode="r")
manager = CachingFileManager(
rasterio.open,
filename,
lock=lock,
mode="r",
kwargs=kwargs,
)
riods = manager.acquire()
if vrt_params is not None:
riods = WarpedVRT(riods, **vrt_params)
Expand Down

0 comments on commit 78cec7c

Please sign in to comment.