Repository: corteva/rioxarray

Issue:
Opening VRT with GCPs results in DataArray of zeros
#### Code Sample, a copy-pastable example if possible

The following loads geo coordinates correctly, but the data array is all zeros
```python
import rioxarray
import rasterio
from rasterio.vrt import WarpedVRT

with rasterio.open('cint16.tif') as src:
    with WarpedVRT(src) as vrt:
        rds = rioxarray.open_rasterio(vrt)
        
rds.values.any() # False
```
#### Problem description

Opening a WarpedVRT with ground control points results in an array of zeros. But using `rio.reproject` works as expected:

#### Expected Output

There should be non-zero data values in the DataArray

```
da = rioxarray.open_rasterio('cint16.tif')
da = da.astype('f4')
daG = da.rio.reproject('EPSG:4326')
daG.values.any() # True
```

I used `cint16.tif` because it is already in rioxarray test data, but here is a gist with another data product with uint16 dtype with some plots too
https://gist.github.com/scottyhq/211d417aa826593d8b3cac1f3367be68 


#### Environment Information

```
rioxarray (0.10.3) deps:
  rasterio: 1.3a3
    xarray: 2022.3.0
      GDAL: 3.4.1

Other python deps:
     scipy: 1.8.0
    pyproj: 3.3.0

System:
    python: 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:25:59)  [GCC 10.3.0]
executable: /srv/conda/envs/sarsen/bin/python
   machine: Linux-5.4.172-90.336.amzn2.x86_64-x86_64-with-glibc2.27
```

#### Installation method
 - conda / conda-forge


Comments:

Patch:
diff --git a/docs/history.rst b/docs/history.rst
index 48dea99..102f0f3 100644
--- a/docs/history.rst
+++ b/docs/history.rst
@@ -3,7 +3,7 @@ History
 
 Latest
 ------
-
+- BUG: Fix WarpedVRT param cache in :func:`rioxarray.open_rasterio` (issue #515)
 
 0.11.0
 ------
diff --git a/rioxarray/_io.py b/rioxarray/_io.py
index 5bd58db..86fa727 100644
--- a/rioxarray/_io.py
+++ b/rioxarray/_io.py
@@ -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,
         )


Test patch:
diff --git a/test/integration/test_integration__io.py b/test/integration/test_integration__io.py
index 7440923..fba3970 100644
--- a/test/integration/test_integration__io.py
+++ b/test/integration/test_integration__io.py
@@ -38,6 +38,11 @@ from test.integration.test_integration_rioxarray import (
     _create_gdal_gcps,
 )
 
+cint_skip = pytest.mark.skipif(
+    rasterio.__version__ < "1.2.4",
+    reason="https://github.com/mapbox/rasterio/issues/2182",
+)
+
 
 @pytest.mark.parametrize(
     "subdataset, variable, group, match",
@@ -932,6 +937,19 @@ def test_rasterio_vrt_gcps(tmp_path):
                 )
 
 
+@cint_skip
+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")
@@ -1150,12 +1168,6 @@ def test_rotation_affine():
             assert rioda.rio.resolution() == (10, 10)
 
 
-cint_skip = pytest.mark.skipif(
-    rasterio.__version__ < "1.2.4",
-    reason="https://github.com/mapbox/rasterio/issues/2182",
-)
-
-
 @cint_skip
 @pytest.mark.parametrize("dtype", [None, "complex_int16"])
 def test_cint16_dtype(dtype, tmp_path):