rioxarray 0.15.1__tar.gz → 0.18.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {rioxarray-0.15.1 → rioxarray-0.18.2}/AUTHORS.rst +10 -1
  2. {rioxarray-0.15.1 → rioxarray-0.18.2}/CONTRIBUTING.rst +3 -2
  3. {rioxarray-0.15.1/rioxarray.egg-info → rioxarray-0.18.2}/PKG-INFO +14 -52
  4. {rioxarray-0.15.1 → rioxarray-0.18.2}/README.rst +1 -1
  5. rioxarray-0.18.2/pyproject.toml +70 -0
  6. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/_io.py +53 -28
  7. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/merge.py +82 -99
  8. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/raster_array.py +97 -41
  9. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/raster_dataset.py +51 -19
  10. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/raster_writer.py +44 -29
  11. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/rioxarray.py +98 -30
  12. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/xarray_plugin.py +5 -0
  13. {rioxarray-0.15.1 → rioxarray-0.18.2/rioxarray.egg-info}/PKG-INFO +14 -52
  14. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray.egg-info/SOURCES.txt +0 -2
  15. rioxarray-0.18.2/rioxarray.egg-info/requires.txt +11 -0
  16. rioxarray-0.18.2/setup.cfg +4 -0
  17. rioxarray-0.15.1/pyproject.toml +0 -6
  18. rioxarray-0.15.1/rioxarray.egg-info/not-zip-safe +0 -1
  19. rioxarray-0.15.1/rioxarray.egg-info/requires.txt +0 -48
  20. rioxarray-0.15.1/setup.cfg +0 -81
  21. {rioxarray-0.15.1 → rioxarray-0.18.2}/LICENSE +0 -0
  22. {rioxarray-0.15.1 → rioxarray-0.18.2}/LICENSE_datacube +0 -0
  23. {rioxarray-0.15.1 → rioxarray-0.18.2}/LICENSE_xarray +0 -0
  24. {rioxarray-0.15.1 → rioxarray-0.18.2}/MANIFEST.in +0 -0
  25. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/__init__.py +0 -0
  26. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/_options.py +0 -0
  27. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/_show_versions.py +0 -0
  28. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/crs.py +0 -0
  29. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/exceptions.py +0 -0
  30. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray/py.typed +0 -0
  31. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray.egg-info/dependency_links.txt +0 -0
  32. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray.egg-info/entry_points.txt +0 -0
  33. {rioxarray-0.15.1 → rioxarray-0.18.2}/rioxarray.egg-info/top_level.txt +0 -0
  34. {rioxarray-0.15.1 → rioxarray-0.18.2}/setup.py +0 -0
@@ -49,13 +49,22 @@ Thanks goes to these wonderful people (`emoji key <https://allcontributors.org/d
49
49
  </tr>
50
50
  <tr>
51
51
  <td align="center"><a href="https://github.com/JessicaS11"><img src="https://avatars.githubusercontent.com/u/11756442?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jessica Scheick</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=JessicaS11" title="Documentation">📖</a></td>
52
- <td align="center"><a href="https://www.linkedin.com/in/micheleclaus/"><img src="https://avatars.githubusercontent.com/u/31700619?v=4?s=100" width="100px;" alt=""/><br /><sub><b>clausmichele</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/pulls?q=is%3Apr+reviewed-by%3Aclausmichele" title="Reviewed Pull Requests">👀</a></td>
52
+ <td align="center"><a href="https://www.linkedin.com/in/micheleclaus/"><img src="https://avatars.githubusercontent.com/u/31700619?v=4?s=100" width="100px;" alt=""/><br /><sub><b>clausmichele</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/pulls?q=is%3Apr+reviewed-by%3Aclausmichele" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/corteva/rioxarray/commits?author=clausmichele" title="Documentation">📖</a></td>
53
53
  <td align="center"><a href="https://github.com/caldwellst"><img src="https://avatars.githubusercontent.com/u/8086547?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Seth Caldwell</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/issues?q=author%3Acaldwellst" title="Bug reports">🐛</a> <a href="https://github.com/corteva/rioxarray/commits?author=caldwellst" title="Code">💻</a></td>
54
54
  <td align="center"><a href="https://github.com/stefank0"><img src="https://avatars.githubusercontent.com/u/32932217?v=4?s=100" width="100px;" alt=""/><br /><sub><b>stefank0</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=stefank0" title="Documentation">📖</a></td>
55
55
  <td align="center"><a href="https://itcarroll.github.io/"><img src="https://avatars.githubusercontent.com/u/3383837?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ian Carroll</b></sub></a><br /><a href="#maintenance-itcarroll" title="Maintenance">🚧</a></td>
56
56
  <td align="center"><a href="https://github.com/yvonnefroehlich"><img src="https://avatars.githubusercontent.com/u/94163266?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yvonne Fröhlich</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=yvonnefroehlich" title="Documentation">📖</a></td>
57
57
  <td align="center"><a href="https://github.com/Kirill888"><img src="https://avatars.githubusercontent.com/u/1428024?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kirill Kouzoubov</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=Kirill888" title="Code">💻</a></td>
58
58
  </tr>
59
+ <tr>
60
+ <td align="center"><a href="https://github.com/xaviernogueira"><img src="https://avatars.githubusercontent.com/u/58796351?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xavier Nogueira</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/issues?q=author%3Axaviernogueira" title="Bug reports">🐛</a></td>
61
+ <td align="center"><a href="https://github.com/valanm22"><img src="https://avatars.githubusercontent.com/u/84893551?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Valan Baptist Mathuranayagam</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=valanm22" title="Documentation">📖</a></td>
62
+ <td align="center"><a href="https://github.com/peterm790"><img src="https://avatars.githubusercontent.com/u/52179978?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Peter Marsh</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=peterm790" title="Code">💻</a> <a href="https://github.com/corteva/rioxarray/commits?author=peterm790" title="Tests">⚠️</a></td>
63
+ <td align="center"><a href="https://github.com/dluks"><img src="https://avatars.githubusercontent.com/u/4911680?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Lusk</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=dluks" title="Code">💻</a> <a href="https://github.com/corteva/rioxarray/commits?author=dluks" title="Documentation">📖</a></td>
64
+ <td align="center"><a href="https://github.com/DahnJ"><img src="https://avatars.githubusercontent.com/u/18722560?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Jahn (dahn)</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=DahnJ" title="Documentation">📖</a></td>
65
+ <td align="center"><a href="https://phofl.github.io/"><img src="https://avatars.githubusercontent.com/u/61934744?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patrick Hoefler</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/issues?q=author%3Aphofl" title="Bug reports">🐛</a></td>
66
+ <td align="center"><a href="https://github.com/dzanaga"><img src="https://avatars.githubusercontent.com/u/8113766?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniele Zanaga</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=dzanaga" title="Documentation">📖</a></td>
67
+ </tr>
59
68
  </table>
60
69
 
61
70
  <!-- markdownlint-restore -->
@@ -78,9 +78,10 @@ Using python::
78
78
  $ python -m venv venv
79
79
  $ . venv/bin/activate
80
80
 
81
- 4. Install your local copy into a virtualenv.
81
+ 4. Install your local copy into a virtualenv::
82
82
 
83
- $ pip install -e .[dev]
83
+ $ python -m pip install -e ".[all]"
84
+ $ python -m pip install -r requirements/dev.txt
84
85
 
85
86
  5. Setup pre-commit hooks::
86
87
 
@@ -1,13 +1,14 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: rioxarray
3
- Version: 0.15.1
3
+ Version: 0.18.2
4
4
  Summary: geospatial xarray extension powered by rasterio
5
- Home-page: https://github.com/corteva/rioxarray
6
- Download-URL: http://python.org/pypi/rioxarray
7
- Author: rioxarray Contributors
5
+ Maintainer: rioxarray Contributors
8
6
  License: Apache
7
+ Project-URL: homepage, https://corteva.github.io/rioxarray/
8
+ Project-URL: documentation, https://corteva.github.io/rioxarray/
9
+ Project-URL: repository, https://github.com/corteva/rioxarray
10
+ Project-URL: changelog, https://corteva.github.io/rioxarray/stable/history.html
9
11
  Keywords: rioxarray,xarray,rasterio
10
- Platform: any
11
12
  Classifier: Development Status :: 4 - Beta
12
13
  Classifier: Intended Audience :: Developers
13
14
  Classifier: Natural Language :: English
@@ -18,64 +19,25 @@ Classifier: Programming Language :: Python
18
19
  Classifier: Programming Language :: Python :: 3.10
19
20
  Classifier: Programming Language :: Python :: 3.11
20
21
  Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
21
23
  Classifier: Programming Language :: Python :: 3
22
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
25
  Classifier: Typing :: Typed
24
26
  Requires-Python: >=3.10
25
27
  Description-Content-Type: text/x-rst
26
28
  License-File: LICENSE
29
+ License-File: LICENSE_datacube
30
+ License-File: LICENSE_xarray
31
+ License-File: AUTHORS.rst
27
32
  Requires-Dist: packaging
28
- Requires-Dist: rasterio>=1.3
29
- Requires-Dist: xarray>=2022.3.0
33
+ Requires-Dist: rasterio>=1.3.7
34
+ Requires-Dist: xarray>=2024.7.0
30
35
  Requires-Dist: pyproj>=3.3
31
36
  Requires-Dist: numpy>=1.23
32
37
  Provides-Extra: interp
33
38
  Requires-Dist: scipy; extra == "interp"
34
- Provides-Extra: doc
35
- Requires-Dist: sphinx-click; extra == "doc"
36
- Requires-Dist: nbsphinx; extra == "doc"
37
- Requires-Dist: sphinx_rtd_theme; extra == "doc"
38
- Provides-Extra: test
39
- Requires-Dist: pytest>=3.6; extra == "test"
40
- Requires-Dist: pytest-cov; extra == "test"
41
- Requires-Dist: pytest-timeout; extra == "test"
42
- Requires-Dist: dask; extra == "test"
43
- Requires-Dist: netcdf4; extra == "test"
44
- Provides-Extra: dev
45
- Requires-Dist: scipy; extra == "dev"
46
- Requires-Dist: sphinx-click; extra == "dev"
47
- Requires-Dist: nbsphinx; extra == "dev"
48
- Requires-Dist: sphinx_rtd_theme; extra == "dev"
49
- Requires-Dist: pytest>=3.6; extra == "dev"
50
- Requires-Dist: pytest-cov; extra == "dev"
51
- Requires-Dist: pytest-timeout; extra == "dev"
52
- Requires-Dist: dask; extra == "dev"
53
- Requires-Dist: netcdf4; extra == "dev"
54
- Requires-Dist: pylint; extra == "dev"
55
- Requires-Dist: mypy; extra == "dev"
56
- Requires-Dist: pre-commit; extra == "dev"
57
39
  Provides-Extra: all
58
40
  Requires-Dist: scipy; extra == "all"
59
- Requires-Dist: sphinx-click; extra == "all"
60
- Requires-Dist: nbsphinx; extra == "all"
61
- Requires-Dist: sphinx_rtd_theme; extra == "all"
62
- Requires-Dist: pytest>=3.6; extra == "all"
63
- Requires-Dist: pytest-cov; extra == "all"
64
- Requires-Dist: pytest-timeout; extra == "all"
65
- Requires-Dist: dask; extra == "all"
66
- Requires-Dist: netcdf4; extra == "all"
67
- Requires-Dist: scipy; extra == "all"
68
- Requires-Dist: sphinx-click; extra == "all"
69
- Requires-Dist: nbsphinx; extra == "all"
70
- Requires-Dist: sphinx_rtd_theme; extra == "all"
71
- Requires-Dist: pytest>=3.6; extra == "all"
72
- Requires-Dist: pytest-cov; extra == "all"
73
- Requires-Dist: pytest-timeout; extra == "all"
74
- Requires-Dist: dask; extra == "all"
75
- Requires-Dist: netcdf4; extra == "all"
76
- Requires-Dist: pylint; extra == "all"
77
- Requires-Dist: mypy; extra == "all"
78
- Requires-Dist: pre-commit; extra == "all"
79
41
 
80
42
  ================
81
43
  rioxarray README
@@ -88,7 +50,7 @@ rasterio xarray extension.
88
50
  :alt: Join the chat at https://gitter.im/rioxarray/community
89
51
  :target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
90
52
 
91
- .. image:: https://img.shields.io/badge/all_contributors-35-orange.svg?style=flat-square
53
+ .. image:: https://img.shields.io/badge/all_contributors-42-orange.svg?style=flat-square
92
54
  :alt: All Contributors
93
55
  :target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
94
56
 
@@ -9,7 +9,7 @@ rasterio xarray extension.
9
9
  :alt: Join the chat at https://gitter.im/rioxarray/community
10
10
  :target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
11
11
 
12
- .. image:: https://img.shields.io/badge/all_contributors-35-orange.svg?style=flat-square
12
+ .. image:: https://img.shields.io/badge/all_contributors-42-orange.svg?style=flat-square
13
13
  :alt: All Contributors
14
14
  :target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
15
15
 
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ # Minimum requirements for the build system to execute.
3
+ requires = ["setuptools", "wheel"]
4
+
5
+ [project]
6
+ name = "rioxarray"
7
+ version = "0.18.2"
8
+ description = "geospatial xarray extension powered by rasterio"
9
+ maintainers = [
10
+ {name = "rioxarray Contributors"},
11
+ ]
12
+ keywords = [
13
+ "rioxarray",
14
+ "xarray",
15
+ "rasterio",
16
+ ]
17
+ readme = "README.rst"
18
+ license = {text = "Apache"}
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "Natural Language :: English",
23
+ "License :: OSI Approved :: Apache Software License",
24
+ "Operating System :: OS Independent",
25
+ "Topic :: Scientific/Engineering :: GIS",
26
+ "Programming Language :: Python",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Programming Language :: Python :: 3",
32
+ "Topic :: Software Development :: Libraries :: Python Modules",
33
+ "Typing :: Typed",
34
+ ]
35
+ requires-python = ">=3.10"
36
+ dependencies = [
37
+ "packaging",
38
+ "rasterio>=1.3.7",
39
+ "xarray>=2024.7.0",
40
+ "pyproj>=3.3",
41
+ "numpy>=1.23",
42
+ ]
43
+
44
+ [project.urls]
45
+ homepage = "https://corteva.github.io/rioxarray/"
46
+ documentation = "https://corteva.github.io/rioxarray/"
47
+ repository = "https://github.com/corteva/rioxarray"
48
+ changelog = "https://corteva.github.io/rioxarray/stable/history.html"
49
+
50
+ [tool.setuptools.packages.find]
51
+ include = ["rioxarray", "rioxarray.*"]
52
+
53
+ [options.package_data]
54
+ rioxarray = [
55
+ "py.typed",
56
+ ]
57
+
58
+ [project.entry-points."xarray.backends"]
59
+ rasterio = "rioxarray.xarray_plugin:RasterioBackend"
60
+
61
+ [project.optional-dependencies]
62
+ interp = [
63
+ "scipy"
64
+ ]
65
+ all = [
66
+ "scipy"
67
+ ]
68
+
69
+ [tool.black]
70
+ target_version = ["py310"]
@@ -7,7 +7,6 @@ Source file: https://github.com/pydata/xarray/blob/1d7bcbdc75b6d556c04e2c7d7a042
7
7
  """
8
8
  # pylint: disable=too-many-lines
9
9
  import contextlib
10
- import functools
11
10
  import importlib.metadata
12
11
  import os
13
12
  import re
@@ -145,7 +144,11 @@ class SingleBandDatasetReader:
145
144
  """
146
145
  read data for the band
147
146
  """
148
- return self._riods.read(indexes=self._bidx + 1, **kwargs)
147
+ if numpy.isscalar(indexes):
148
+ indexes = self._bidx + 1
149
+ else:
150
+ indexes = [self._bidx + 1]
151
+ return self._riods.read(indexes=indexes, **kwargs)
149
152
 
150
153
  def tags(self, bidx=None, **kwargs): # pylint: disable=unused-argument
151
154
  """
@@ -292,6 +295,7 @@ class RasterioArrayWrapper(BackendArray):
292
295
 
293
296
  def __init__(
294
297
  self,
298
+ *,
295
299
  manager,
296
300
  lock,
297
301
  name,
@@ -309,7 +313,6 @@ class RasterioArrayWrapper(BackendArray):
309
313
  riods = _ensure_warped_vrt(manager.acquire(), vrt_params)
310
314
  self.vrt_params = vrt_params
311
315
  self._shape = (riods.count, riods.height, riods.width)
312
-
313
316
  self._dtype = None
314
317
  self._unsigned_dtype = None
315
318
  self._fill_value = riods.nodata
@@ -325,7 +328,7 @@ class RasterioArrayWrapper(BackendArray):
325
328
  )
326
329
  if self._unsigned_dtype is not None and self._fill_value is not None:
327
330
  self._fill_value = self._unsigned_dtype.type(self._fill_value)
328
- if self._unsigned_dtype is None and dtype.kind not in ("i", "u"):
331
+ if self._unsigned_dtype is None:
329
332
  warnings.warn(
330
333
  f"variable {name!r} has _Unsigned attribute but is not "
331
334
  "of integer type. Ignoring attribute.",
@@ -510,7 +513,7 @@ def _to_numeric(value: Any) -> float:
510
513
  return value
511
514
 
512
515
 
513
- def _parse_tag(key: str, value: Any) -> tuple[str, Any]:
516
+ def _parse_tag(*, key: str, value: Any) -> tuple[str, Any]:
514
517
  # NC_GLOBAL is appended to tags with netcdf driver and is not really needed
515
518
  key = key.split("NC_GLOBAL#")[-1]
516
519
  if value.startswith("{") and value.endswith("}"):
@@ -528,7 +531,7 @@ def _parse_tag(key: str, value: Any) -> tuple[str, Any]:
528
531
  def _parse_tags(tags: dict) -> dict:
529
532
  parsed_tags = {}
530
533
  for key, value in tags.items():
531
- key, value = _parse_tag(key, value)
534
+ key, value = _parse_tag(key=key, value=value)
532
535
  parsed_tags[key] = value
533
536
  return parsed_tags
534
537
 
@@ -550,7 +553,7 @@ NETCDF_DTYPE_MAP = {
550
553
  }
551
554
 
552
555
 
553
- def _load_netcdf_attrs(tags: dict, data_array: DataArray) -> None:
556
+ def _load_netcdf_attrs(*, tags: dict, data_array: DataArray) -> None:
554
557
  """
555
558
  Loads the netCDF attributes into the data array
556
559
 
@@ -558,7 +561,7 @@ def _load_netcdf_attrs(tags: dict, data_array: DataArray) -> None:
558
561
  - variable_name#attr_name: attr_value
559
562
  """
560
563
  for key, value in tags.items():
561
- key, value = _parse_tag(key, value)
564
+ key, value = _parse_tag(key=key, value=value)
562
565
  key_split = key.split("#")
563
566
  if len(key_split) != 2:
564
567
  continue
@@ -567,7 +570,7 @@ def _load_netcdf_attrs(tags: dict, data_array: DataArray) -> None:
567
570
  data_array.coords[variable_name].attrs.update({attr_name: value})
568
571
 
569
572
 
570
- def _parse_netcdf_attr_array(attr: Union[NDArray, str], dtype=None) -> NDArray:
573
+ def _parse_netcdf_attr_array(attr: Union[NDArray, str], *, dtype=None) -> NDArray:
571
574
  """
572
575
  Expected format: '{2,6}' or '[2. 6.]'
573
576
  """
@@ -667,7 +670,7 @@ def _get_rasterio_attrs(riods: RasterioReader):
667
670
  if len(set(riods.scales)) > 1:
668
671
  attrs["scales"] = riods.scales
669
672
  warnings.warn(
670
- "Offsets differ across bands. The 'scale_factor' attribute will "
673
+ "Scales differ across bands. The 'scale_factor' attribute will "
671
674
  "not be added. See the 'scales' attribute."
672
675
  )
673
676
  else:
@@ -773,7 +776,7 @@ def _pop_global_netcdf_attrs_from_vars(dataset_to_clean: Dataset) -> Dataset:
773
776
 
774
777
 
775
778
  def _subdataset_groups_to_dataset(
776
- dim_groups: dict[Hashable, dict[Hashable, DataArray]], global_tags: dict
779
+ *, dim_groups: dict[Hashable, dict[Hashable, DataArray]], global_tags: dict
777
780
  ) -> Union[Dataset, list[Dataset]]:
778
781
  if dim_groups:
779
782
  dataset: Union[Dataset, list[Dataset]] = []
@@ -798,6 +801,7 @@ def _subdataset_groups_to_dataset(
798
801
 
799
802
  def _load_subdatasets(
800
803
  riods: RasterioReader,
804
+ *,
801
805
  group: Optional[Union[str, list[str], tuple[str, ...]]],
802
806
  variable: Optional[Union[str, list[str], tuple[str, ...]]],
803
807
  parse_coordinates: bool,
@@ -843,6 +847,7 @@ def _load_subdatasets(
843
847
 
844
848
  def _load_bands_as_variables(
845
849
  riods: RasterioReader,
850
+ *,
846
851
  parse_coordinates: bool,
847
852
  chunks: Optional[Union[int, tuple, dict]],
848
853
  cache: Optional[bool],
@@ -881,7 +886,7 @@ def _load_bands_as_variables(
881
886
  **open_kwargs,
882
887
  )
883
888
  .squeeze() # type: ignore
884
- .drop("band") # type: ignore
889
+ .drop_vars("band") # type: ignore
885
890
  )
886
891
  dataset = Dataset(data_vars, attrs=global_tags)
887
892
 
@@ -894,10 +899,12 @@ def _load_bands_as_variables(
894
899
 
895
900
 
896
901
  def _prepare_dask(
902
+ *,
897
903
  result: DataArray,
898
904
  riods: RasterioReader,
899
905
  filename: Union[str, os.PathLike],
900
906
  chunks: Union[int, tuple, dict],
907
+ bidx: Optional[int] = None,
901
908
  ) -> DataArray:
902
909
  """
903
910
  Prepare the data for dask computations
@@ -922,14 +929,18 @@ def _prepare_dask(
922
929
  chunks=(1, "auto", "auto"),
923
930
  shape=(riods.count, riods.height, riods.width),
924
931
  dtype=_rasterio_to_numpy_dtype(riods.dtypes),
925
- previous_chunks=tuple((c,) for c in block_shape),
932
+ previous_chunks=block_shape,
926
933
  )
927
- token = tokenize(filename, mtime, chunks)
934
+ token_filename = filename
935
+ if bidx is not None:
936
+ token_filename = f"{filename}-{bidx}"
937
+ token = tokenize(token_filename, mtime, chunks)
928
938
  name_prefix = f"open_rasterio-{token}"
929
939
  return result.chunk(chunks, name_prefix=name_prefix, token=token)
930
940
 
931
941
 
932
942
  def _handle_encoding(
943
+ *,
933
944
  result: DataArray,
934
945
  mask_and_scale: bool,
935
946
  masked: bool,
@@ -946,8 +957,12 @@ def _handle_encoding(
946
957
  variables.pop_to(
947
958
  result.attrs, result.encoding, "scale_factor", name=da_name
948
959
  )
960
+ if "scales" in result.attrs:
961
+ variables.pop_to(result.attrs, result.encoding, "scales", name=da_name)
949
962
  if "add_offset" in result.attrs:
950
963
  variables.pop_to(result.attrs, result.encoding, "add_offset", name=da_name)
964
+ if "offsets" in result.attrs:
965
+ variables.pop_to(result.attrs, result.encoding, "offsets", name=da_name)
951
966
  if masked:
952
967
  if "_FillValue" in result.attrs:
953
968
  variables.pop_to(result.attrs, result.encoding, "_FillValue", name=da_name)
@@ -985,6 +1000,7 @@ def open_rasterio(
985
1000
  rasterio.vrt.WarpedVRT,
986
1001
  SingleBandDatasetReader,
987
1002
  ],
1003
+ *,
988
1004
  parse_coordinates: Optional[bool] = None,
989
1005
  chunks: Optional[Union[int, tuple, dict]] = None,
990
1006
  cache: Optional[bool] = None,
@@ -1004,10 +1020,7 @@ def open_rasterio(
1004
1020
 
1005
1021
  This should work with any file that rasterio can open (most often:
1006
1022
  geoTIFF). The x and y coordinates are generated automatically from the
1007
- file's geoinformation, shifted to the center of each pixel (see
1008
- `"PixelIsArea" Raster Space
1009
- <http://web.archive.org/web/20160326194152/http://remotesensing.org/geotiff/spec/geotiff2.5.html#2.5.2>`_
1010
- for more information).
1023
+ file's geoinformation and refer to the center of the pixel.
1011
1024
 
1012
1025
  .. versionadded:: 0.13 band_as_variable
1013
1026
 
@@ -1080,10 +1093,8 @@ def open_rasterio(
1080
1093
  vrt_params = None
1081
1094
  file_opener = rasterio.open
1082
1095
  if isinstance(filename, SingleBandDatasetReader):
1083
- file_opener = functools.partial(
1084
- _single_band_open,
1085
- bidx=filename._bidx,
1086
- )
1096
+ file_opener = _single_band_open
1097
+ open_kwargs.update(bidx=filename._bidx)
1087
1098
  vrt_params = filename._vrt_params
1088
1099
  if isinstance(filename, (rasterio.io.DatasetReader, SingleBandDatasetReader)):
1089
1100
  filename = filename.name
@@ -1202,7 +1213,9 @@ def open_rasterio(
1202
1213
  # Get geospatial coordinates
1203
1214
  if parse_coordinates:
1204
1215
  coords.update(
1205
- _generate_spatial_coords(riods.transform, riods.width, riods.height)
1216
+ _generate_spatial_coords(
1217
+ affine=riods.transform, width=riods.width, height=riods.height
1218
+ )
1206
1219
  )
1207
1220
 
1208
1221
  unsigned = None
@@ -1216,8 +1229,8 @@ def open_rasterio(
1216
1229
  da_name = attrs.pop("NETCDF_VARNAME", default_name)
1217
1230
  data: Any = indexing.LazilyOuterIndexedArray(
1218
1231
  RasterioArrayWrapper(
1219
- manager,
1220
- lock,
1232
+ manager=manager,
1233
+ lock=lock,
1221
1234
  name=da_name,
1222
1235
  vrt_params=vrt_params,
1223
1236
  masked=masked,
@@ -1237,7 +1250,7 @@ def open_rasterio(
1237
1250
  result.encoding = encoding
1238
1251
 
1239
1252
  # update attributes from NetCDF attributes
1240
- _load_netcdf_attrs(riods.tags(), result)
1253
+ _load_netcdf_attrs(tags=riods.tags(), data_array=result)
1241
1254
  result = _decode_datetime_cf(
1242
1255
  result, decode_times=decode_times, decode_timedelta=decode_timedelta
1243
1256
  )
@@ -1247,7 +1260,13 @@ def open_rasterio(
1247
1260
  result.attrs["_FillValue"] = result.dtype.type(result.attrs["_FillValue"])
1248
1261
 
1249
1262
  # handle encoding
1250
- _handle_encoding(result, mask_and_scale, masked, da_name, unsigned=unsigned)
1263
+ _handle_encoding(
1264
+ result=result,
1265
+ mask_and_scale=mask_and_scale,
1266
+ masked=masked,
1267
+ da_name=da_name,
1268
+ unsigned=unsigned,
1269
+ )
1251
1270
  # Affine transformation matrix (always available)
1252
1271
  # This describes coefficients mapping pixel coordinates to CRS
1253
1272
  # For serialization store as tuple of 6 floats, the last row being
@@ -1261,7 +1280,13 @@ def open_rasterio(
1261
1280
  result.rio.write_gcps(*riods.gcps, inplace=True)
1262
1281
 
1263
1282
  if chunks is not None:
1264
- result = _prepare_dask(result, riods, filename, chunks)
1283
+ result = _prepare_dask(
1284
+ result=result,
1285
+ riods=riods,
1286
+ filename=filename,
1287
+ chunks=chunks,
1288
+ bidx=open_kwargs.get("bidx"),
1289
+ )
1265
1290
  else:
1266
1291
  result.encoding["preferred_chunks"] = {
1267
1292
  result.rio.y_dim: riods.block_shapes[0][0],