Skip to content

Commit 78cec7c

Browse files
pkopparladcheriankeewis
authored
Kwargs to rasterio open (#5609)
* 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]>
1 parent da99a56 commit 78cec7c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

doc/whats-new.rst

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ New Features
9797
- Allow removal of the coordinate attribute ``coordinates`` on variables by setting ``.attrs['coordinates']= None``
9898
(:issue:`5510`).
9999
By `Elle Smith <https://github.com/ellesmith88>`_.
100+
- Added ``**kwargs`` argument to :py:meth:`open_rasterio` to access overviews (:issue:`3269`).
101+
By `Pushkar Kopparla <https://github.com/pkopparla>`_.
100102
- Added :py:meth:`DataArray.to_numpy`, :py:meth:`DataArray.as_numpy`, and :py:meth:`Dataset.as_numpy`. (:pull:`5568`).
101103
By `Tom Nicholas <https://github.com/TomNicholas>`_.
102104
- Units in plot labels are now automatically inferred from wrapped :py:meth:`pint.Quantity` arrays. (:pull:`5561`).

xarray/backends/rasterio_.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,14 @@ def default(s):
162162
return parsed_meta
163163

164164

165-
def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None, lock=None):
165+
def open_rasterio(
166+
filename,
167+
parse_coordinates=None,
168+
chunks=None,
169+
cache=None,
170+
lock=None,
171+
**kwargs,
172+
):
166173
"""Open a file with rasterio (experimental).
167174
168175
This should work with any file that rasterio can open (most often:
@@ -272,7 +279,13 @@ def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None, loc
272279
if lock is None:
273280
lock = RASTERIO_LOCK
274281

275-
manager = CachingFileManager(rasterio.open, filename, lock=lock, mode="r")
282+
manager = CachingFileManager(
283+
rasterio.open,
284+
filename,
285+
lock=lock,
286+
mode="r",
287+
kwargs=kwargs,
288+
)
276289
riods = manager.acquire()
277290
if vrt_params is not None:
278291
riods = WarpedVRT(riods, **vrt_params)

0 commit comments

Comments
 (0)