Skip to content

Commit

Permalink
BUG: Fix WarpedVRT param cache in open_rasterio
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Apr 22, 2022
1 parent 131b2cb commit 7212265
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ History

Latest
------

- BUG: Fix WarpedVRT param cache in :func:`rioxarray.open_rasterio` (issue #515)

0.11.0
------
Expand Down
10 changes: 5 additions & 5 deletions rioxarray/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,15 +811,15 @@ def open_rasterio(
filename = vrt.src_dataset.name
vrt_params = dict(
src_crs=vrt.src_crs.to_string() if vrt.src_crs else None,
crs=vrt.crs.to_string() if vrt.crs else None,
crs=vrt.dst_crs.to_string() if vrt.dst_crs else None,
resampling=vrt.resampling,
tolerance=vrt.tolerance,
src_nodata=vrt.src_nodata,
nodata=vrt.nodata,
width=vrt.width,
height=vrt.height,
nodata=vrt.dst_nodata,
width=vrt.dst_width,
height=vrt.dst_height,
src_transform=vrt.src_transform,
transform=vrt.transform,
transform=vrt.dst_transform,
dtype=vrt.working_dtype,
warp_extras=vrt.warp_extras,
)
Expand Down
12 changes: 12 additions & 0 deletions test/integration/test_integration__io.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,18 @@ def test_rasterio_vrt_gcps(tmp_path):
)


def test_rasterio_vrt_gcps__data_exists():
# https://github.com/corteva/rioxarray/issues/515
vrt_file = os.path.join(TEST_INPUT_DATA_DIR, "cint16.tif")
with rasterio.open(vrt_file) as src:
crs = src.gcps[1]
# NOTE: Eventually src_crs will not need to be provided
# https://github.com/mapbox/rasterio/pull/2193
with rasterio.vrt.WarpedVRT(src, src_crs=crs) as vrt:
rds = rioxarray.open_rasterio(vrt)
assert rds.values.any()


@pytest.mark.parametrize("lock", [True, False])
def test_open_cog(lock):
cog_file = os.path.join(TEST_INPUT_DATA_DIR, "cog.tif")
Expand Down

0 comments on commit 7212265

Please sign in to comment.