From ec07342cd2839d095ebc43a2fc0fff70198c1cd7 Mon Sep 17 00:00:00 2001 From: snowman2 Date: Fri, 22 Apr 2022 09:57:54 -0500 Subject: [PATCH] BUG: Always generate coordinates in rio.reproject when GCPS|RCPS present --- docs/history.rst | 1 + rioxarray/raster_array.py | 11 +++++++++-- test/integration/test_integration_rioxarray.py | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/history.rst b/docs/history.rst index 102f0f3c..08395a23 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -4,6 +4,7 @@ History Latest ------ - BUG: Fix WarpedVRT param cache in :func:`rioxarray.open_rasterio` (issue #515) +- BUG: Always generate coordinates in `rio.reproject` when GCPS|RCPS present (issue #517) 0.11.0 ------ diff --git a/rioxarray/raster_array.py b/rioxarray/raster_array.py index 29cc8af6..69002160 100644 --- a/rioxarray/raster_array.py +++ b/rioxarray/raster_array.py @@ -438,7 +438,8 @@ def reproject( if gcps: kwargs.setdefault("gcps", gcps) - src_affine = None if "gcps" in kwargs else self.transform(recalc=True) + gcps_or_rcps = "gcps" in kwargs or "rcps" in kwargs + src_affine = None if gcps_or_rcps else self.transform(recalc=True) if transform is None: dst_affine, dst_width, dst_height = _make_dst_affine( self._obj, self.crs, dst_crs, resolution, shape, **kwargs @@ -480,7 +481,13 @@ def reproject( xda = xarray.DataArray( name=self._obj.name, data=dst_data, - coords=_make_coords(self._obj, dst_affine, dst_width, dst_height), + coords=_make_coords( + src_data_array=self._obj, + dst_affine=dst_affine, + dst_width=dst_width, + dst_height=dst_height, + force_generate=gcps_or_rcps, + ), dims=tuple(dst_dims), attrs=new_attrs, ) diff --git a/test/integration/test_integration_rioxarray.py b/test/integration/test_integration_rioxarray.py index 31923326..cbc7c1bf 100644 --- a/test/integration/test_integration_rioxarray.py +++ b/test/integration/test_integration_rioxarray.py @@ -1034,6 +1034,8 @@ def test_reproject__gcps_kwargs(tmp_path): 2818720.0, ) ) + assert (rds.coords["x"].values > 11000).all() + assert (rds.coords["y"].values > 281700).all() def test_reproject_match(modis_reproject_match):