Repository: corteva/rioxarray

Issue:
interpolate_na raises TypeError when using `rioxarray.open_rasterio` instead of `xarray.open_rasterio`

#### Code Sample
The following causes a crash:

```python
import xarray
import rioxarray

file_url = 'https://neo.sci.gsfc.nasa.gov/archive/geotiff.float/MY1DMW_CHLORA/MY1DMW_CHLORA_2020-03-21.FLOAT.TIFF'
ds = rioxarray.open_rasterio(file_url)
ds = ds.rio.write_crs("EPSG:4326")
ds = ds.sel(
    y=slice(55, 30), x=slice(165, 180)
)
ds = ds.rio.interpolate_na(method="linear")
```
while replacing `rioxarray.open_rasterio` with `xarray.open_rasterio` works fine.

#### Problem description

The problem is a crash with the error:
 `TypeError: float() argument must be a string or a number, not 'NoneType'`:
This also happens for other TIFFs. 

#### Environment Information

```
rioxarray (0.3.0) deps:
  rasterio: 1.1.8
    xarray: 0.16.2
      GDAL: 2.4.4

Other python deps:
     scipy: 1.5.4
    pyproj: 3.0.0.post1

System:
    python: 3.8.3 (default, Nov  5 2020, 11:18:23)  [Clang 9.1.0 (clang-902.0.39.1)]
executable: /Users/user/.pyenv/versions/3.8.3/envs/myenv/bin/python3.8
   machine: macOS-10.13.6-x86_64-i386-64bit
```

#### Installation method
pypi


Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=h1) Report
> Merging [#256](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=desc) (ff4ec47) into [master](https://codecov.io/gh/corteva/rioxarray/commit/63ce87f92835897d46aaa270f5ec07aca4e72cda?el=desc) (63ce87f) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/corteva/rioxarray/pull/256/graphs/tree.svg?width=650&height=150&src=pr&token=C8QK7VO1OF)](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #256   +/-   ##
=======================================
  Coverage   93.78%   93.79%           
=======================================
  Files          12       12           
  Lines        1352     1354    +2     
=======================================
+ Hits         1268     1270    +2     
  Misses         84       84           
```


| [Impacted Files](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [rioxarray/raster\_array.py](https://codecov.io/gh/corteva/rioxarray/pull/256/diff?src=pr&el=tree#diff-cmlveGFycmF5L3Jhc3Rlcl9hcnJheS5weQ==) | `98.25% <100.00%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=footer). Last update [63ce87f...ff4ec47](https://codecov.io/gh/corteva/rioxarray/pull/256?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/rioxarray/raster_array.py b/rioxarray/raster_array.py
index f77531fd..287ad8f2 100644
--- a/rioxarray/raster_array.py
+++ b/rioxarray/raster_array.py
@@ -789,6 +789,12 @@ class RasterArray(XRasterBase):
         :obj:`xarray.DataArray`:
             An interpolated :obj:`xarray.DataArray` object.
         """
+        if self.nodata is None:
+            raise RioXarrayError(
+                "nodata not found. Please set the nodata with 'rio.write_nodata()'."
+                f"{_get_data_var_message(self._obj)}"
+            )
+
         extra_dim = self._check_dimensions()
         if extra_dim:
             interp_data = []


Test patch:
diff --git a/test/integration/test_integration_rioxarray.py b/test/integration/test_integration_rioxarray.py
index 34aaac14..b0da9a32 100644
--- a/test/integration/test_integration_rioxarray.py
+++ b/test/integration/test_integration_rioxarray.py
@@ -2290,3 +2290,20 @@ def test_estimate_utm_crs__out_of_bounds():
     else:
         with pytest.raises(RuntimeError, match=r"Unable to determine UTM CRS"):
             xds.rio.estimate_utm_crs()
+
+
+def test_interpolate_na_missing_nodata():
+    test_da = xarray.DataArray(
+        name="missing",
+        data=numpy.zeros((5, 5)),
+        dims=("y", "x"),
+        coords={"y": numpy.arange(1, 6), "x": numpy.arange(2, 7)},
+    )
+    match = (
+        r"nodata not found\. Please set the nodata with "
+        r"'rio\.write_nodata\(\)'\. Data variable: missing"
+    )
+    with pytest.raises(RioXarrayError, match=match):
+        test_da.rio.interpolate_na()
+    with pytest.raises(RioXarrayError, match=match):
+        test_da.to_dataset().rio.interpolate_na()