rioxarray 0.15.7__tar.gz → 0.17.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 (30) hide show
  1. {rioxarray-0.15.7 → rioxarray-0.17.0}/AUTHORS.rst +1 -0
  2. {rioxarray-0.15.7 → rioxarray-0.17.0}/CONTRIBUTING.rst +2 -2
  3. {rioxarray-0.15.7/rioxarray.egg-info → rioxarray-0.17.0}/PKG-INFO +1 -1
  4. {rioxarray-0.15.7 → rioxarray-0.17.0}/pyproject.toml +1 -1
  5. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/raster_array.py +23 -13
  6. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/raster_dataset.py +5 -0
  7. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/raster_writer.py +5 -1
  8. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/rioxarray.py +37 -4
  9. {rioxarray-0.15.7 → rioxarray-0.17.0/rioxarray.egg-info}/PKG-INFO +1 -1
  10. {rioxarray-0.15.7 → rioxarray-0.17.0}/LICENSE +0 -0
  11. {rioxarray-0.15.7 → rioxarray-0.17.0}/LICENSE_datacube +0 -0
  12. {rioxarray-0.15.7 → rioxarray-0.17.0}/LICENSE_xarray +0 -0
  13. {rioxarray-0.15.7 → rioxarray-0.17.0}/MANIFEST.in +0 -0
  14. {rioxarray-0.15.7 → rioxarray-0.17.0}/README.rst +0 -0
  15. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/__init__.py +0 -0
  16. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/_io.py +0 -0
  17. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/_options.py +0 -0
  18. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/_show_versions.py +0 -0
  19. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/crs.py +0 -0
  20. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/exceptions.py +0 -0
  21. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/merge.py +0 -0
  22. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/py.typed +0 -0
  23. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray/xarray_plugin.py +0 -0
  24. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray.egg-info/SOURCES.txt +0 -0
  25. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray.egg-info/dependency_links.txt +0 -0
  26. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray.egg-info/entry_points.txt +0 -0
  27. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray.egg-info/requires.txt +0 -0
  28. {rioxarray-0.15.7 → rioxarray-0.17.0}/rioxarray.egg-info/top_level.txt +0 -0
  29. {rioxarray-0.15.7 → rioxarray-0.17.0}/setup.cfg +0 -0
  30. {rioxarray-0.15.7 → rioxarray-0.17.0}/setup.py +0 -0
@@ -60,6 +60,7 @@ Thanks goes to these wonderful people (`emoji key <https://allcontributors.org/d
60
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
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
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>
63
64
  </tr>
64
65
  </table>
65
66
 
@@ -78,9 +78,9 @@ 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
- $ python -m pip install -e .[all]
83
+ $ python -m pip install -e ".[all]"
84
84
  $ python -m pip install -r requirements/dev.txt
85
85
 
86
86
  5. Setup pre-commit hooks::
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rioxarray
3
- Version: 0.15.7
3
+ Version: 0.17.0
4
4
  Summary: geospatial xarray extension powered by rasterio
5
5
  Maintainer: rioxarray Contributors
6
6
  License: Apache
@@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"]
4
4
 
5
5
  [project]
6
6
  name = "rioxarray"
7
- version = "0.15.7"
7
+ version = "0.17.0"
8
8
  description = "geospatial xarray extension powered by rasterio"
9
9
  maintainers = [
10
10
  {name = "rioxarray Contributors"},
@@ -47,21 +47,23 @@ from rioxarray.rioxarray import (
47
47
  # Based on: https://github.com/OSGeo/gdal/blob/
48
48
  # dee861e7c91c2da7ef8ff849947713e4d9bd115c/
49
49
  # swig/python/gdal-utils/osgeo_utils/gdal_calc.py#L61
50
+ # And: https://github.com/rasterio/rasterio/blob/
51
+ # 9e643c3f563a679aa5400d9b1a263df97b34f9e0/rasterio/dtypes.py#L99-L112
50
52
  _NODATA_DTYPE_MAP = {
51
53
  1: 255, # GDT_Byte
52
54
  2: 65535, # GDT_UInt16
53
55
  3: -32768, # GDT_Int16
54
- 4: 4294967293, # GDT_UInt32
55
- 5: -2147483647, # GDT_Int32
56
- 6: 3.402823466e38, # GDT_Float32
57
- 7: 1.7976931348623158e308, # GDT_Float64
56
+ 4: 4294967295, # GDT_UInt32
57
+ 5: -2147483648, # GDT_Int32
58
+ 6: numpy.nan, # GDT_Float32
59
+ 7: numpy.nan, # GDT_Float64
58
60
  8: None, # GDT_CInt16
59
61
  9: None, # GDT_CInt32
60
- 10: 3.402823466e38, # GDT_CFloat32
61
- 11: 1.7976931348623158e308, # GDT_CFloat64
62
- 12: None, # GDT_Int64
63
- 13: None, # GDT_UInt64
64
- 14: None, # GDT_Int8
62
+ 10: numpy.nan, # GDT_CFloat32
63
+ 11: numpy.nan, # GDT_CFloat64
64
+ 12: 18446744073709551615, # GDT_UInt64
65
+ 13: -9223372036854775808, # GDT_Int64
66
+ 14: -128, # GDT_Int8
65
67
  }
66
68
 
67
69
 
@@ -713,10 +715,12 @@ class RasterArray(XRasterBase):
713
715
  auto_expand: Union[bool, int] = False,
714
716
  auto_expand_limit: int = 3,
715
717
  crs: Optional[Any] = None,
718
+ allow_one_dimensional_raster: bool = False,
716
719
  ) -> xarray.DataArray:
717
720
  """Clip the :obj:`xarray.DataArray` by a bounding box.
718
721
 
719
722
  .. versionadded:: 0.12 crs
723
+ .. versionadded:: 0.16 allow_one_dimensional_raster
720
724
 
721
725
  Parameters
722
726
  ----------
@@ -736,16 +740,19 @@ class RasterArray(XRasterBase):
736
740
  crs: :obj:`rasterio.crs.CRS`, optional
737
741
  The CRS of the bounding box. Default is to assume it is the same
738
742
  as the dataset.
743
+ allow_one_dimensional_raster: bool, optional
744
+ If True, allow clipping to/from a one dimensional raster.
739
745
 
740
746
  Returns
741
747
  -------
742
748
  xarray.DataArray:
743
749
  The clipped object.
744
750
  """
745
- if self.width == 1 or self.height == 1:
751
+ if not allow_one_dimensional_raster and (self.width == 1 or self.height == 1):
746
752
  raise OneDimensionalRaster(
747
753
  "At least one of the raster x,y coordinates has only one point."
748
- f"{_get_data_var_message(self._obj)}"
754
+ f"{_get_data_var_message(self._obj)}. "
755
+ "Set allow_one_dimensional_raster=True to disable this error."
749
756
  )
750
757
 
751
758
  if crs is not None and self.crs is None:
@@ -819,11 +826,14 @@ class RasterArray(XRasterBase):
819
826
  raise NoDataInBounds(
820
827
  f"No data found in bounds.{_get_data_var_message(self._obj)}"
821
828
  )
822
- if cl_array.rio.width == 1 or cl_array.rio.height == 1:
829
+ if not allow_one_dimensional_raster and (
830
+ cl_array.rio.width == 1 or cl_array.rio.height == 1
831
+ ):
823
832
  raise OneDimensionalRaster(
824
833
  "At least one of the clipped raster x,y coordinates"
825
834
  " has only one point."
826
- f"{_get_data_var_message(self._obj)}"
835
+ f"{_get_data_var_message(self._obj)}. "
836
+ "Set allow_one_dimensional_raster=True to disable this error."
827
837
  )
828
838
 
829
839
  # make sure correct attributes preserved & projection added
@@ -256,12 +256,14 @@ class RasterDataset(XRasterBase):
256
256
  auto_expand: Union[bool, int] = False,
257
257
  auto_expand_limit: int = 3,
258
258
  crs: Optional[Any] = None,
259
+ allow_one_dimensional_raster: bool = False,
259
260
  ) -> xarray.Dataset:
260
261
  """Clip the :class:`xarray.Dataset` by a bounding box in dimensions 'x'/'y'.
261
262
 
262
263
  .. warning:: Clips variables that have dimensions 'x'/'y'. Others are appended as is.
263
264
 
264
265
  .. versionadded:: 0.12 crs
266
+ .. versionadded:: 0.16 allow_one_dimensional_raster
265
267
 
266
268
  Parameters
267
269
  ----------
@@ -281,6 +283,8 @@ class RasterDataset(XRasterBase):
281
283
  crs: :obj:`rasterio.crs.CRS`, optional
282
284
  The CRS of the bounding box. Default is to assume it is the same
283
285
  as the dataset.
286
+ allow_one_dimensional_raster: bool, optional
287
+ If True, allow clipping to/from a one dimensional raster.
284
288
 
285
289
  Returns
286
290
  -------
@@ -302,6 +306,7 @@ class RasterDataset(XRasterBase):
302
306
  auto_expand=auto_expand,
303
307
  auto_expand_limit=auto_expand_limit,
304
308
  crs=crs,
309
+ allow_one_dimensional_raster=allow_one_dimensional_raster,
305
310
  )
306
311
  )
307
312
  except MissingSpatialDimensionError:
@@ -123,7 +123,11 @@ def _ensure_nodata_dtype(original_nodata, new_dtype):
123
123
  if numpy.issubdtype(new_dtype, numpy.complexfloating):
124
124
  nodata = original_nodata
125
125
  else:
126
- original_nodata = float(original_nodata)
126
+ original_nodata = (
127
+ float(original_nodata)
128
+ if not numpy.issubdtype(type(original_nodata), numpy.integer)
129
+ else original_nodata
130
+ )
127
131
  failure_message = (
128
132
  f"Unable to convert nodata value ({original_nodata}) to "
129
133
  f"new dtype ({new_dtype})."
@@ -2,6 +2,7 @@
2
2
  This module is an extension for xarray to provide rasterio capabilities
3
3
  to xarray datasets/dataarrays.
4
4
  """
5
+
5
6
  # pylint: disable=too-many-lines
6
7
  import json
7
8
  import math
@@ -305,7 +306,7 @@ class XRasterBase:
305
306
  # pyproj CRS if possible for performance
306
307
  for crs_attr in ("spatial_ref", "crs_wkt"):
307
308
  try:
308
- self.set_crs(
309
+ self._set_crs(
309
310
  self._obj.coords[self.grid_mapping].attrs[crs_attr],
310
311
  inplace=True,
311
312
  )
@@ -315,14 +316,14 @@ class XRasterBase:
315
316
 
316
317
  # look in grid_mapping
317
318
  try:
318
- self.set_crs(
319
+ self._set_crs(
319
320
  pyproj.CRS.from_cf(self._obj.coords[self.grid_mapping].attrs),
320
321
  inplace=True,
321
322
  )
322
323
  except (KeyError, pyproj.exceptions.CRSError):
323
324
  try:
324
325
  # look in attrs for 'crs'
325
- self.set_crs(self._obj.attrs["crs"], inplace=True)
326
+ self._set_crs(self._obj.attrs["crs"], inplace=True)
326
327
  except KeyError:
327
328
  self._crs = False
328
329
  return None
@@ -360,6 +361,10 @@ class XRasterBase:
360
361
  Set the CRS value for the Dataset/DataArray without modifying
361
362
  the dataset/data array.
362
363
 
364
+ .. deprecated:: 0.15.8
365
+ It is recommended to use `rio.write_crs()` instead. This
366
+ method will likely be removed in a future release.
367
+
363
368
  Parameters
364
369
  ----------
365
370
  input_crs: object
@@ -372,6 +377,34 @@ class XRasterBase:
372
377
  :obj:`xarray.Dataset` | :obj:`xarray.DataArray`:
373
378
  Dataset with crs attribute.
374
379
  """
380
+ warnings.warn(
381
+ "It is recommended to use 'rio.write_crs()' instead. 'rio.set_crs()' will likely"
382
+ "be removed in a future release.",
383
+ FutureWarning,
384
+ stacklevel=2,
385
+ )
386
+
387
+ return self._set_crs(input_crs, inplace=inplace)
388
+
389
+ def _set_crs(
390
+ self, input_crs: Any, inplace: bool = True
391
+ ) -> Union[xarray.Dataset, xarray.DataArray]:
392
+ """
393
+ Set the CRS value for the Dataset/DataArray without modifying
394
+ the dataset/data array.
395
+
396
+ Parameters
397
+ ----------
398
+ input_crs: object
399
+ Anything accepted by `rasterio.crs.CRS.from_user_input`.
400
+ inplace: bool, optional
401
+ If True, it will write to the existing dataset. Default is False.
402
+
403
+ Returns
404
+ -------
405
+ xarray.Dataset | xarray.DataArray
406
+ Dataset with crs attribute.
407
+ """
375
408
  crs = crs_from_user_input(input_crs)
376
409
  obj = self._get_obj(inplace=inplace)
377
410
  obj.rio._crs = crs
@@ -483,7 +516,7 @@ class XRasterBase:
483
516
  >>> raster = raster.rio.write_crs("epsg:4326")
484
517
  """
485
518
  if input_crs is not None:
486
- data_obj = self.set_crs(input_crs, inplace=inplace)
519
+ data_obj = self._set_crs(input_crs, inplace=inplace)
487
520
  else:
488
521
  data_obj = self._get_obj(inplace=inplace)
489
522
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rioxarray
3
- Version: 0.15.7
3
+ Version: 0.17.0
4
4
  Summary: geospatial xarray extension powered by rasterio
5
5
  Maintainer: rioxarray Contributors
6
6
  License: Apache
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