Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: corteva/rioxarray
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.16.0
Choose a base ref
...
head repository: corteva/rioxarray
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.17.0
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Jul 8, 2024

  1. MNT: Prepare for next release cycle

    snowman2 committed Jul 8, 2024
    Copy the full SHA
    c688bcc View commit details

Commits on Jul 18, 2024

  1. CI: Remove apache arrow apt sources (#798)

    snowman2 authored Jul 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    df2a6de View commit details
  2. REF:reproject: Make NaN default float nodata & update integer defaults (

    snowman2 authored Jul 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    0ece381 View commit details
  3. MNT: version 0.17.0

    snowman2 committed Jul 18, 2024
    Copy the full SHA
    6303bb6 View commit details
Showing with 51 additions and 11 deletions.
  1. +1 −0 .github/workflows/tests.yaml
  2. +4 −0 docs/history.rst
  3. +1 −1 pyproject.toml
  4. +11 −9 rioxarray/raster_array.py
  5. +5 −1 rioxarray/raster_writer.py
  6. +29 −0 test/integration/test_integration_rioxarray.py
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ jobs:

- name: Update
run: |
rm /etc/apt/sources.list.d/apache-arrow.sources
apt-get update
apt-get -y install software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
4 changes: 4 additions & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
History
=======

0.17.0
------
- REF:reproject: Make NaN default float nodata & update integer defaults

0.16.0
------
- ENH: Add `allow_one_dimensional_raster` option to `rio.clip_box` (issue #708)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"]

[project]
name = "rioxarray"
version = "0.16.0"
version = "0.17.0"
description = "geospatial xarray extension powered by rasterio"
maintainers = [
{name = "rioxarray Contributors"},
20 changes: 11 additions & 9 deletions rioxarray/raster_array.py
Original file line number Diff line number Diff line change
@@ -47,21 +47,23 @@
# Based on: https://github.com/OSGeo/gdal/blob/
# dee861e7c91c2da7ef8ff849947713e4d9bd115c/
# swig/python/gdal-utils/osgeo_utils/gdal_calc.py#L61
# And: https://github.com/rasterio/rasterio/blob/
# 9e643c3f563a679aa5400d9b1a263df97b34f9e0/rasterio/dtypes.py#L99-L112
_NODATA_DTYPE_MAP = {
1: 255, # GDT_Byte
2: 65535, # GDT_UInt16
3: -32768, # GDT_Int16
4: 4294967293, # GDT_UInt32
5: -2147483647, # GDT_Int32
6: 3.402823466e38, # GDT_Float32
7: 1.7976931348623158e308, # GDT_Float64
4: 4294967295, # GDT_UInt32
5: -2147483648, # GDT_Int32
6: numpy.nan, # GDT_Float32
7: numpy.nan, # GDT_Float64
8: None, # GDT_CInt16
9: None, # GDT_CInt32
10: 3.402823466e38, # GDT_CFloat32
11: 1.7976931348623158e308, # GDT_CFloat64
12: None, # GDT_Int64
13: None, # GDT_UInt64
14: None, # GDT_Int8
10: numpy.nan, # GDT_CFloat32
11: numpy.nan, # GDT_CFloat64
12: 18446744073709551615, # GDT_UInt64
13: -9223372036854775808, # GDT_Int64
14: -128, # GDT_Int8
}


6 changes: 5 additions & 1 deletion rioxarray/raster_writer.py
Original file line number Diff line number Diff line change
@@ -123,7 +123,11 @@ def _ensure_nodata_dtype(original_nodata, new_dtype):
if numpy.issubdtype(new_dtype, numpy.complexfloating):
nodata = original_nodata
else:
original_nodata = float(original_nodata)
original_nodata = (
float(original_nodata)
if not numpy.issubdtype(type(original_nodata), numpy.integer)
else original_nodata
)
failure_message = (
f"Unable to convert nodata value ({original_nodata}) to "
f"new dtype ({new_dtype})."
29 changes: 29 additions & 0 deletions test/integration/test_integration_rioxarray.py
Original file line number Diff line number Diff line change
@@ -2165,6 +2165,35 @@ def test_reproject_transform_missing_shape():
assert reprojected.rio.transform() == affine


@pytest.mark.parametrize(
"dtype, expected_nodata",
[
(numpy.uint8, 255),
(numpy.int8, -128),
(numpy.uint16, 65535),
(numpy.int16, -32768),
(numpy.uint32, 4294967295),
(numpy.int32, -2147483648),
(numpy.float32, numpy.nan),
(numpy.float64, numpy.nan),
(numpy.complex64, numpy.nan),
(numpy.complex128, numpy.nan),
(numpy.uint64, 18446744073709551615),
(numpy.int64, -9223372036854775808),
],
)
def test_reproject_default_nodata(dtype, expected_nodata):
test_da = xarray.DataArray(
numpy.zeros((5, 5), dtype=dtype),
dims=("y", "x"),
coords={"y": numpy.arange(1, 6), "x": numpy.arange(2, 7)},
).rio.write_crs("epsg:3857", inplace=True)
if numpy.isnan(expected_nodata):
assert numpy.isnan(test_da.rio.reproject(4326).rio.nodata)
else:
assert test_da.rio.reproject(4326).rio.nodata == expected_nodata


class CustomCRS:
@property
def wkt(self):