Skip to content

Commit

Permalink
BUG: Always generate coordinates in rio.reproject when GCPS|RCPS present
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Apr 22, 2022
1 parent 7344ea3 commit ec07342
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------
Expand Down
11 changes: 9 additions & 2 deletions rioxarray/raster_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
2 changes: 2 additions & 0 deletions test/integration/test_integration_rioxarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ec07342

Please sign in to comment.