rioxarray 0.22.0__tar.gz → 0.23.0__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 (37) hide show
  1. {rioxarray-0.22.0 → rioxarray-0.23.0}/AUTHORS.rst +2 -0
  2. {rioxarray-0.22.0/rioxarray.egg-info → rioxarray-0.23.0}/PKG-INFO +3 -4
  3. {rioxarray-0.22.0 → rioxarray-0.23.0}/README.rst +1 -1
  4. {rioxarray-0.22.0 → rioxarray-0.23.0}/pyproject.toml +5 -7
  5. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_convention/zarr.py +59 -25
  6. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/enum.py +3 -3
  7. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/raster_array.py +2 -2
  8. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/raster_dataset.py +3 -3
  9. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/rioxarray.py +1 -1
  10. {rioxarray-0.22.0 → rioxarray-0.23.0/rioxarray.egg-info}/PKG-INFO +3 -4
  11. {rioxarray-0.22.0 → rioxarray-0.23.0}/CONTRIBUTING.rst +0 -0
  12. {rioxarray-0.22.0 → rioxarray-0.23.0}/LICENSE +0 -0
  13. {rioxarray-0.22.0 → rioxarray-0.23.0}/LICENSE_datacube +0 -0
  14. {rioxarray-0.22.0 → rioxarray-0.23.0}/LICENSE_xarray +0 -0
  15. {rioxarray-0.22.0 → rioxarray-0.23.0}/MANIFEST.in +0 -0
  16. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/__init__.py +0 -0
  17. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_convention/__init__.py +0 -0
  18. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_convention/_base.py +0 -0
  19. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_convention/_core.py +0 -0
  20. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_convention/cf.py +0 -0
  21. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_io.py +0 -0
  22. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_options.py +0 -0
  23. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_show_versions.py +0 -0
  24. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/_spatial_utils.py +0 -0
  25. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/crs.py +0 -0
  26. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/exceptions.py +0 -0
  27. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/merge.py +0 -0
  28. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/py.typed +0 -0
  29. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/raster_writer.py +0 -0
  30. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray/xarray_plugin.py +0 -0
  31. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray.egg-info/SOURCES.txt +0 -0
  32. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray.egg-info/dependency_links.txt +0 -0
  33. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray.egg-info/entry_points.txt +0 -0
  34. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray.egg-info/requires.txt +0 -0
  35. {rioxarray-0.22.0 → rioxarray-0.23.0}/rioxarray.egg-info/top_level.txt +0 -0
  36. {rioxarray-0.22.0 → rioxarray-0.23.0}/setup.cfg +0 -0
  37. {rioxarray-0.22.0 → rioxarray-0.23.0}/setup.py +0 -0
@@ -70,6 +70,8 @@ Thanks goes to these wonderful people (`emoji key <https://allcontributors.org/d
70
70
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/trchudley"><img src="https://avatars.githubusercontent.com/u/24896931?v=4?s=100" width="100px;" alt="Tom Chudley"/><br /><sub><b>Tom Chudley</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=trchudley" title="Code">💻</a></td>
71
71
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/acoque"><img src="https://avatars.githubusercontent.com/u/35691279?v=4?s=100" width="100px;" alt="acoque"/><br /><sub><b>acoque</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=acoque" title="Documentation">📖</a></td>
72
72
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/martijnvandermarel"><img src="https://avatars.githubusercontent.com/u/23376251?v=4?s=100" width="100px;" alt="Martijn van der Marel"/><br /><sub><b>Martijn van der Marel</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/issues?q=author%3Amartijnvandermarel" title="Bug reports">🐛</a></td>
73
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/emmanuelmathot"><img src="https://avatars.githubusercontent.com/u/1178857?v=4?s=100" width="100px;" alt="Emmanuel Mathot"/><br /><sub><b>Emmanuel Mathot</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=emmanuelmathot" title="Code">💻</a> <a href="https://github.com/corteva/rioxarray/commits?author=emmanuelmathot" title="Documentation">📖</a> <a href="https://github.com/corteva/rioxarray/commits?author=emmanuelmathot" title="Tests">⚠️</a></td>
74
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Breeze-Hu"><img src="https://avatars.githubusercontent.com/u/173059909?v=4?s=100" width="100px;" alt="Breeze-Hu"/><br /><sub><b>Breeze-Hu</b></sub></a><br /><a href="#maintenance-Breeze-Hu" title="Maintenance">🚧</a></td>
73
75
  </tr>
74
76
  </tbody>
75
77
  </table>
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rioxarray
3
- Version: 0.22.0
3
+ Version: 0.23.0
4
4
  Summary: geospatial xarray extension powered by rasterio
5
5
  Maintainer: rioxarray Contributors
6
- License: Apache
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: homepage, https://corteva.github.io/rioxarray/
8
8
  Project-URL: documentation, https://corteva.github.io/rioxarray/
9
9
  Project-URL: repository, https://github.com/corteva/rioxarray
@@ -12,7 +12,6 @@ Keywords: rioxarray,xarray,rasterio
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Natural Language :: English
15
- Classifier: License :: OSI Approved :: Apache Software License
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Topic :: Scientific/Engineering :: GIS
18
17
  Classifier: Programming Language :: Python
@@ -50,7 +49,7 @@ rasterio xarray extension.
50
49
  :alt: Join the chat at https://gitter.im/rioxarray/community
51
50
  :target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
52
51
 
53
- .. image:: https://img.shields.io/badge/all_contributors-45-orange.svg?style=flat-square
52
+ .. image:: https://img.shields.io/badge/all_contributors-47-orange.svg?style=flat-square
54
53
  :alt: All Contributors
55
54
  :target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
56
55
 
@@ -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-45-orange.svg?style=flat-square
12
+ .. image:: https://img.shields.io/badge/all_contributors-47-orange.svg?style=flat-square
13
13
  :alt: All Contributors
14
14
  :target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
15
15
 
@@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"]
4
4
 
5
5
  [project]
6
6
  name = "rioxarray"
7
- version = "0.22.0"
7
+ version = "0.23.0"
8
8
  description = "geospatial xarray extension powered by rasterio"
9
9
  maintainers = [
10
10
  {name = "rioxarray Contributors"},
@@ -15,12 +15,12 @@ keywords = [
15
15
  "rasterio",
16
16
  ]
17
17
  readme = "README.rst"
18
- license = {text = "Apache"}
18
+ license = "Apache-2.0"
19
+ license-files = ["LICENSE*", "AUTHORS.rst"]
19
20
  classifiers = [
20
21
  "Development Status :: 4 - Beta",
21
22
  "Intended Audience :: Developers",
22
23
  "Natural Language :: English",
23
- "License :: OSI Approved :: Apache Software License",
24
24
  "Operating System :: OS Independent",
25
25
  "Topic :: Scientific/Engineering :: GIS",
26
26
  "Programming Language :: Python",
@@ -45,6 +45,7 @@ dependencies = [
45
45
  doc = [
46
46
  "sphinx-click",
47
47
  "nbsphinx",
48
+ "ipython",
48
49
  "sphinx_rtd_theme",
49
50
  ]
50
51
  test = [
@@ -77,7 +78,7 @@ changelog = "https://corteva.github.io/rioxarray/stable/history.html"
77
78
  [tool.setuptools.packages.find]
78
79
  include = ["rioxarray", "rioxarray.*"]
79
80
 
80
- [options.package_data]
81
+ [tool.setuptools.package-data]
81
82
  rioxarray = [
82
83
  "py.typed",
83
84
  ]
@@ -92,6 +93,3 @@ interp = [
92
93
  all = [
93
94
  "scipy"
94
95
  ]
95
-
96
- [tool.black]
97
- target_version = ["py310"]
@@ -8,6 +8,7 @@ This module provides functions for reading geospatial metadata according to:
8
8
  from typing import Optional, Union
9
9
 
10
10
  import rasterio.crs
11
+ import rasterio.transform
11
12
  import xarray
12
13
  from affine import Affine
13
14
 
@@ -183,6 +184,42 @@ def _parse_transform_from_attrs(
183
184
  return None
184
185
 
185
186
 
187
+ # ============================================================================
188
+ # Writing utilities
189
+ # ============================================================================
190
+
191
+ _CONVENTION_DICTS = {"proj:": PROJ_CONVENTION, "spatial:": SPATIAL_CONVENTION}
192
+
193
+
194
+ def add_convention_declaration(attrs: dict, convention_name: str) -> dict:
195
+ """
196
+ Add a convention to the zarr_conventions list in attrs, idempotent.
197
+
198
+ Parameters
199
+ ----------
200
+ attrs : dict
201
+ Attributes dictionary to modify in place
202
+ convention_name : str
203
+ Name of the convention to declare (e.g., "proj:" or "spatial:")
204
+
205
+ Returns
206
+ -------
207
+ dict
208
+ The modified attrs dict
209
+ """
210
+ if has_convention_declared(attrs, convention_name):
211
+ return attrs
212
+ zarr_conventions = list(attrs.get("zarr_conventions") or [])
213
+ zarr_conventions.append(_CONVENTION_DICTS[convention_name])
214
+ attrs["zarr_conventions"] = zarr_conventions
215
+ return attrs
216
+
217
+
218
+ def format_spatial_transform(affine: Affine) -> list:
219
+ """Convert Affine to spatial:transform array [a, b, c, d, e, f]."""
220
+ return [affine.a, affine.b, affine.c, affine.d, affine.e, affine.f]
221
+
222
+
186
223
  # ============================================================================
187
224
  # ZarrConvention class implementing ConventionProtocol
188
225
  # ============================================================================
@@ -270,9 +307,7 @@ class ZarrConvention:
270
307
  **kwargs, # pylint: disable=unused-argument
271
308
  ) -> Union[xarray.Dataset, xarray.DataArray]:
272
309
  """
273
- Write CRS using Zarr conventions.
274
-
275
- Note: Writing support will be implemented in a future PR.
310
+ Write CRS using Zarr proj: convention.
276
311
 
277
312
  Parameters
278
313
  ----------
@@ -281,22 +316,17 @@ class ZarrConvention:
281
316
  crs : rasterio.crs.CRS
282
317
  CRS to write
283
318
  **kwargs
284
- Additional convention-specific parameters
319
+ Additional convention-specific parameters (e.g., grid_mapping_name for CF;
320
+ silently ignored here)
285
321
 
286
322
  Returns
287
323
  -------
288
324
  xarray.Dataset or xarray.DataArray
289
325
  Object with CRS written
290
-
291
- Raises
292
- ------
293
- NotImplementedError
294
- Zarr write support is not yet implemented
295
326
  """
296
- raise NotImplementedError(
297
- "Zarr CRS writing is not yet implemented. "
298
- "Use Convention.CF for writing or wait for a future release."
299
- )
327
+ add_convention_declaration(obj.attrs, "proj:")
328
+ obj.attrs["proj:wkt2"] = crs.to_wkt()
329
+ return obj
300
330
 
301
331
  @classmethod
302
332
  def write_transform(
@@ -307,9 +337,7 @@ class ZarrConvention:
307
337
  **kwargs, # pylint: disable=unused-argument
308
338
  ) -> Union[xarray.Dataset, xarray.DataArray]:
309
339
  """
310
- Write transform using Zarr conventions.
311
-
312
- Note: Writing support will be implemented in a future PR.
340
+ Write transform using Zarr spatial: convention.
313
341
 
314
342
  Parameters
315
343
  ----------
@@ -318,19 +346,25 @@ class ZarrConvention:
318
346
  transform : affine.Affine
319
347
  Transform to write
320
348
  **kwargs
321
- Additional convention-specific parameters
349
+ Additional convention-specific parameters (e.g., grid_mapping_name for CF;
350
+ silently ignored here)
322
351
 
323
352
  Returns
324
353
  -------
325
354
  xarray.Dataset or xarray.DataArray
326
355
  Object with transform written
327
-
328
- Raises
329
- ------
330
- NotImplementedError
331
- Zarr write support is not yet implemented
332
356
  """
333
- raise NotImplementedError(
334
- "Zarr transform writing is not yet implemented. "
335
- "Use Convention.CF for writing or wait for a future release."
357
+ add_convention_declaration(obj.attrs, "spatial:")
358
+ obj.attrs["spatial:transform"] = format_spatial_transform(transform)
359
+ y_dim = obj.rio.y_dim
360
+ x_dim = obj.rio.x_dim
361
+ height = obj.sizes[y_dim]
362
+ width = obj.sizes[x_dim]
363
+ obj.attrs["spatial:dimensions"] = [y_dim, x_dim]
364
+ obj.attrs["spatial:shape"] = [height, width]
365
+ left, bottom, right, top = rasterio.transform.array_bounds(
366
+ height, width, transform
336
367
  )
368
+ obj.attrs["spatial:bbox"] = [left, bottom, right, top]
369
+ obj.attrs["spatial:registration"] = "pixel"
370
+ return obj
@@ -34,9 +34,9 @@ class Convention(Enum):
34
34
 
35
35
  References
36
36
  ----------
37
- .. [1] CF Conventions: https://github.com/cf-convention/cf-conventions
38
- .. [2] Zarr spatial convention: https://github.com/zarr-conventions/spatial
39
- .. [3] Zarr geo-proj convention: https://github.com/zarr-conventions/geo-proj
37
+ - CF Conventions: https://github.com/cf-convention/cf-conventions
38
+ - Zarr spatial convention: https://github.com/zarr-conventions/spatial
39
+ - Zarr geo-proj convention: https://github.com/zarr-conventions/geo-proj
40
40
  """
41
41
 
42
42
  #: Climate and Forecasts convention (default)
@@ -202,7 +202,7 @@ class RasterArray(XRasterBase):
202
202
  resolution: Optional[Union[float, tuple[float, float]]] = None,
203
203
  shape: Optional[tuple[int, int]] = None,
204
204
  transform: Optional[Affine] = None,
205
- resampling: Optional[Union[Resampling | str]] = Resampling.nearest,
205
+ resampling: Optional[Union[Resampling, str]] = Resampling.nearest,
206
206
  nodata: Optional[float] = None,
207
207
  **kwargs,
208
208
  ) -> xarray.DataArray:
@@ -430,7 +430,7 @@ class RasterArray(XRasterBase):
430
430
  self,
431
431
  match_data_array: Union[xarray.DataArray, xarray.Dataset],
432
432
  *,
433
- resampling: Optional[Union[Resampling | str]] = Resampling.nearest,
433
+ resampling: Optional[Union[Resampling, str]] = Resampling.nearest,
434
434
  **reproject_kwargs,
435
435
  ) -> xarray.DataArray:
436
436
  """
@@ -25,7 +25,7 @@ class RasterDataset(XRasterBase):
25
25
 
26
26
  @property
27
27
  def vars(self) -> list:
28
- """list: Returns non-coordinate varibles"""
28
+ """list: Returns non-coordinate variables."""
29
29
  return list(self._obj.data_vars)
30
30
 
31
31
  @property
@@ -63,7 +63,7 @@ class RasterDataset(XRasterBase):
63
63
  resolution: Optional[Union[float, tuple[float, float]]] = None,
64
64
  shape: Optional[tuple[int, int]] = None,
65
65
  transform: Optional[Affine] = None,
66
- resampling: Optional[Union[Resampling | str]] = Resampling.nearest,
66
+ resampling: Optional[Union[Resampling, str]] = Resampling.nearest,
67
67
  nodata: Optional[float] = None,
68
68
  **kwargs,
69
69
  ) -> xarray.Dataset:
@@ -145,7 +145,7 @@ class RasterDataset(XRasterBase):
145
145
  self,
146
146
  match_data_array: Union[xarray.DataArray, xarray.Dataset],
147
147
  *,
148
- resampling: Optional[Union[Resampling | str]] = Resampling.nearest,
148
+ resampling: Optional[Union[Resampling, str]] = Resampling.nearest,
149
149
  **reproject_kwargs,
150
150
  ) -> xarray.Dataset:
151
151
  """
@@ -130,7 +130,7 @@ class XRasterBase:
130
130
 
131
131
  .. deprecated:: 0.15.8
132
132
  It is recommended to use `rio.write_crs()` instead. This
133
- method will likely be removed in a future release.
133
+ method will likely be removed in a future release.
134
134
 
135
135
  Parameters
136
136
  ----------
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rioxarray
3
- Version: 0.22.0
3
+ Version: 0.23.0
4
4
  Summary: geospatial xarray extension powered by rasterio
5
5
  Maintainer: rioxarray Contributors
6
- License: Apache
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: homepage, https://corteva.github.io/rioxarray/
8
8
  Project-URL: documentation, https://corteva.github.io/rioxarray/
9
9
  Project-URL: repository, https://github.com/corteva/rioxarray
@@ -12,7 +12,6 @@ Keywords: rioxarray,xarray,rasterio
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Natural Language :: English
15
- Classifier: License :: OSI Approved :: Apache Software License
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Topic :: Scientific/Engineering :: GIS
18
17
  Classifier: Programming Language :: Python
@@ -50,7 +49,7 @@ rasterio xarray extension.
50
49
  :alt: Join the chat at https://gitter.im/rioxarray/community
51
50
  :target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
52
51
 
53
- .. image:: https://img.shields.io/badge/all_contributors-45-orange.svg?style=flat-square
52
+ .. image:: https://img.shields.io/badge/all_contributors-47-orange.svg?style=flat-square
54
53
  :alt: All Contributors
55
54
  :target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
56
55
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes